Quantcast
Channel: Json.NET
Viewing all articles
Browse latest Browse all 1767

Closed Unassigned: Namespace Prefix is missing during Xml Serialization [24920]

$
0
0
Dear All,

I am working on a project which would like to serialize the existing XML (including some xml namespace) into JSON to save into RavenDB. However, I found the prefix of the sub-elements (with the same name) will be removed while serializing into a JSON Array. For example,

{
"books": {
"@xmlns": "http://www.example.com/bookCollection",
"book": [
{
"@publisher": "QUE",
"@xmlns:bk": "http://www.example.com/book",
"bk:title": "XML By Example",
"bk:author": "Benoit Marchal",
"bk:publication-date": "1999-12-31"
},
{
"@publisher": "Addison Wesley",
"@xmlns:bk": "http://www.example.com/book",
"bk:title": "Essential C++",
"bk:author": "Stanley Lippman",
"bk:publication-date": "2000-10-31"
},
{
"@publisher": "Addison Wesley",
"@xmlns:bk": "http://www.example.com/book",
"bk:title": "Mythical Man Month",
"bk:author": "Frederick Brooks",
"bk:publication-date": "1995-06-30"
}
}

It should be bk:book instead of book. When I deserialize this JSON back to XmlDocument, the namespace of book element is not correct. Please help. Thanks a lot.

Regards,
Mac

Viewing all articles
Browse latest Browse all 1767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>