For more information about using XMLSerializer
in Firefox extensions, please see the documentation for nsIDOMSerializer
.
XMLSerializer.serializeToString
()XMLSerializer.serializeToStream()
var s = new XMLSerializer(); var d = document; var str = s.serializeToString(d); alert(str);
The next example uses XMLSerializer with insertAdjacentHTML() to insert a newly created DOM Node into the Document's body. Because insertAdjacentHTML() accepts a string and not a Node for its second parameter, XMLSerializer is used to first convert the node into a string.
var inp = document.createElement('input'); var XMLS = new XMLSerializer(); var inp_xmls = XMLS.serializeToString(inp); // First convert DOM node into a string // Insert a newly created node into the document's body document.body.insertAdjacentHTML('afterbegin', inp_xmls);
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 9.0 | (Yes) | 3.0.4 |
serializeToStream()
| No support | Removed in 20.0 (20.0) | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | (Yes) | ? | ? | ? |
serializeToStream()
| No support | Removed in 20.0 (20.0) | No support | No support | No support |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XMLSerializer