XMLSerializer
From MDC
XMLSerializer can be used to convert DOM subtree or DOM document into text. XMLSerializer is available to unprivileged scripts.
XMLSerializer is mainly useful for applications and extensions based on Mozilla platform. While it's available to web pages, it's not part of any standard and level of support in other browsers is unknown.
[edit] Methods
- serializeToString
- Returns the serialized subtree in the form of a string
- serializeToStream
- The subtree rooted by the specified element is serialized to a byte stream using the character set specified.
[edit] Example
var s = new XMLSerializer(); var d = document; var str = s.serializeToString(d); alert(str);
var s = new XMLSerializer();
var stream = {
close : function()
{
alert("Stream closed");
},
flush : function()
{
},
write : function(string, count)
{
alert("'" + string + "'\n bytes count: " + count + "");
}
};
s.serializeToStream(document, stream, "UTF-8");
[edit] See also
- Reference (XULPlanet)
- Parsing and serializing XML
- Parsing and serializing XML (XULPlanet)
- Parsing and serializing XML (MozillaZine)
- XMLHttpRequest
- DOMParser