1

Closed

Namespace Prefix is missing during Xml Serialization

description

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
Closed Dec 19, 2013 at 6:58 PM by JamesNK

comments

JamesNK wrote Dec 6, 2013 at 10:58 AM

Please add a repro that includes the original XML.