xmlString = anXMLSerializer.serializeToString(rootNode);
Nodeto use as the root of the DOM tree or subtree for which to construct an XML representation.
DOMString containing the XML representation of the specified DOM tree.
- The specified
rootNodeis not a compatible node type. The root node must be either
- The tree could not be successfully serialized, probably due to issues with the content's compatibility with XML serialization.
- A serialization of HTML was requested but could not succeed due to the content not being well-formed.
The following types are also permitted as descendants of the root node, in addition to
If any other type is encountered, a
TypeError exception is thrown.
There are some things worth noting about the XML output by
- For XML serializations,
Attrnodes are always serialized with their
namespaceURIintact. This may mean that a previously-specified
prefixor default namespace may be dropped or altered.
- The resulting XML is compatible with the HTML parser.
- Elements in the HTML namespace that have no child nodes (thereby representing empty
tags) are serialized with both begin and end tags
"<someelement></someelement>") instead of using the empty-element tag (
No specification found
No specification data found for
Check for problems with this page or contribute a missing
spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.
BCD tables only load in the browser