Hi there @tyrasd,
Great library, thanks a lot!
Here's an example that works perfectly in Chrome 58 and Firefox 53:
<html>
<head>
<title>XML Serialization</title>
</head>
<body>
<script src="jxon.js"></script>
<script>
var xml = '<?xml version="1.0"?><People xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://MyNS.com"><Person><Id>a012345d-12bc-41fe-a35d-ff713bc876e0</Id><Name>Complete Automatically?</Name><Prompt>Would you like to complete this...</Prompt><Options><Option><Text>Automatically</Text><Value>Automatic Name</Value></Option><Option><Text>Manually</Text><Value>Manual Name</Value></Option></Options><Value>Current Name</Value></Person></People>';
var json = JXON.stringToJs(xml);
console.log(JSON.stringify(json));
var desXml = JXON.jsToString(json);
console.log(desXml);
</script>
</body>
</html>
Output:
{
"People": {
"Person": {
"Id": "a012345d-12bc-41fe-a35d-ff713bc876e0",
"Name": "Complete Automatically?",
"Prompt": "Would you like to complete this...",
"Options": {
"Option": [{
"Text": "Automatically",
"Value": "Automatic Name"
}, {
"Text": "Manually",
"Value": "Manual Name"
}
]
},
"Value": "Current Name"
},
"$xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"$xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
"$xmlns": "http://MyNS.com"
}
}
<People xmlns="http://MyNS.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Person>
<Id>a012345d-12bc-41fe-a35d-ff713bc876e0</Id>
<Name>Complete Automatically?</Name>
<Prompt>Would you like to complete this...</Prompt>
<Options>
<Option>
<Text>Automatically</Text>
<Value>Automatic Name</Value>
</Option>
<Option>
<Text>Manually</Text>
<Value>Manual Name</Value>
</Option>
</Options>
<Value>Current Name</Value>
</Person>
</People>
In IE11, the same code produces identical JSON, but the XML looks like this:
<People xmlns="http://MyNS.com" xmlns:NS1="" NS1:xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:NS2="" NS2:xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Person>
<Id>a012345d-12bc-41fe-a35d-ff713bc876e0</Id>
<Name>Complete Automatically?</Name>
<Prompt>Would you like to complete this...</Prompt>
<Options>
<Option>
<Text>Automatically</Text>
<Value>Automatic Name</Value>
</Option>
<Option>
<Text>Manually</Text>
<Value>Manual Name</Value>
</Option>
</Options>
<Value>Current Name</Value>
</Person>
</People>
So there are these empty xmlns:NSx="" namespaces and the actual namespaces are prefixed incorrectly.
Is there a way to get IE11 to serialize namespaces correctly?
Hi there @tyrasd,
Great library, thanks a lot!
Here's an example that works perfectly in Chrome 58 and Firefox 53:
Output:
{ "People": { "Person": { "Id": "a012345d-12bc-41fe-a35d-ff713bc876e0", "Name": "Complete Automatically?", "Prompt": "Would you like to complete this...", "Options": { "Option": [{ "Text": "Automatically", "Value": "Automatic Name" }, { "Text": "Manually", "Value": "Manual Name" } ] }, "Value": "Current Name" }, "$xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "$xmlns:xsd": "http://www.w3.org/2001/XMLSchema", "$xmlns": "http://MyNS.com" } }In IE11, the same code produces identical JSON, but the XML looks like this:
So there are these empty
xmlns:NSx=""namespaces and the actual namespaces are prefixed incorrectly.Is there a way to get IE11 to serialize namespaces correctly?