We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The XML declaration is not serialized, try the code:
let doc = new window.DOMParser().parseFromString('<?xml version="1.0" encoding="utf-8" standalone="yes"?><a>Ahoy</a>', 'application/xml'); console.log(new window.XMLSerializer().serializeToString(doc));
Chrome output: <?xml version="1.0" encoding="utf-8" standalone="yes"?><a>Ahoy</a> jsdom 15.1.1, w3c-xmlserializer 1.1.2 output: <a>Ahoy</a>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><a>Ahoy</a>
<a>Ahoy</a>
The text was updated successfully, but these errors were encountered:
You can work around it like this:
let doc = new window.DOMParser().parseFromString('<a>Ahoy</a>', 'application/xml'); doc.insertBefore(doc.createProcessingInstruction('xml', 'version="1.0" encoding="utf-8" standalone="yes"'), doc.firstChild); console.log(new window.XMLSerializer().serializeToString(doc));
Sorry, something went wrong.
@yingted I just do a simple workaround:
let str = new window.XMLSerializer().serializeToString(doc); if (!str.startsWith("<?xml")) str = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>' + str;
No branches or pull requests
The XML declaration is not serialized, try the code:
Chrome output:
<?xml version="1.0" encoding="utf-8" standalone="yes"?><a>Ahoy</a>
jsdom 15.1.1, w3c-xmlserializer 1.1.2 output:
<a>Ahoy</a>
The text was updated successfully, but these errors were encountered: