XMLSerializer returns wrong text
Reported by
microshi...@gmail.com,
Jul 30
|
||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Steps to reproduce the problem:
var xmlText = `<?xml version="1.0" encoding="UTF-8"?>
<Ping>
<Value>Test</Value>
</Ping>`;
var xml = new DOMParser().parseFromString(xmlText, "application/xml");
var xmlSerializedText = new XMLSerializer().serializeToString(xml);
if (xmlSerializedText !== xmlText) {
console.log(xmlSerializedText);
throw Error("Wrong serialized text");
}
alert("Success");
What is the expected behavior?
Must show Success dialog if serialized text is equal to xmlText variable
What went wrong?
Serialized text is different from xmlText variable
<?xml version="1.0" encoding="UTF-8"?> <- Doesn't have \n symbol
Did this work before? N/A
Does this work in other browsers? Yes
Chrome version: 67.0.3396.99 Channel: n/a
OS Version: OS X 10.13.4
Flash Version:
You can run test script http://jsfiddle.net/rydcgx76/1/
Mozilla works fine
Safari has the same problem
,
Jul 30
#c1 is right. We have no ways to preserve whitespace outside of the root element. The specification about serialization is here: https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node If we follow it, we should not serialize <?xml version...?> too. Reporter, would you file a specification bug on https://github.com/w3c/DOM-Parsing/issues please? We can't implement the behavior which does not match to the specification. |
||
►
Sign in to add a comment |
||
Comment 1 by woxxom@gmail.com
, Jul 30