HTML DOM
The XMLSerializer() constructor creates a new XMLSerializer.
Syntax
new XMLSerializer()
Parameters
None.
Return value
A new XMLSerializer object.
Examples
Serializing XML into a string
This example serializes an entire document into a string containing XML.
const s = new XMLSerializer();
const d = document;
const str = s.serializeToString(d);
saveXML(str);
This involves creating a new XMLSerializer object, then passing the Document to be serialized into XMLSerializer.serializeToString, which returns the XML equivalent of the document. saveXML() represents a function that would then save the serialized string.
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
