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.
- Returns the serialized subtree in the form of a string
var s = new XMLSerializer(); var d = document.body; var str = s.serializeToString(d); alert(str);