Created
November 19, 2018 21:31
-
-
Save Phrogz/50274eb18c4cf8ca92c9e511bd280ff3 to your computer and use it in GitHub Desktop.
Revisions
-
Phrogz created this gist
Nov 19, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ doc = (new DOMParser).parseFromString('<r xmlns="uri1" xmlns:xx="uri2"><b/></r>', 'text/xml'); doc.querySelector('b').setAttributeNS('uri2', 'foo', 'bar'); (new XMLSerializer).serializeToString(doc); // "<r xmlns="uri1" xmlns:xx="uri2"><b xmlns:ns14641696="uri2" ns14641696:foo="bar"/></r>" doc = (new DOMParser).parseFromString('<r xmlns="uri1" xmlns:xx="uri2"><b/></r>', 'text/xml'); doc.querySelector('b').setAttributeNS('uri2', 'xx:foo', 'bar'); (new XMLSerializer).serializeToString(doc); // "<r xmlns="uri1" xmlns:xx="uri2"><b xx:foo="bar"/></r>" doc.querySelector('b').setAttributeNS('uri2', 'foo2', 'bar2'); (new XMLSerializer).serializeToString(doc); // "<r xmlns="uri1" xmlns:xx="uri2"><b xx:foo="bar" xmlns:ns14641696="uri2" ns14641696:foo2="bar2"/></r>"