XMLSerializer: XMLSerializer() constructor
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
TheXMLSerializer() constructor creates a newXMLSerializer.
In this article
Syntax
js
new XMLSerializer()Parameters
None.
Return value
A newXMLSerializer object.
Examples
>Serializing XML into a string
This example serializes an entire document into a string containing XML.
js
const s = new XMLSerializer();const d = document;const str = s.serializeToString(d);saveXML(str);This involves creating a newXMLSerializer object, then passing theDocument to be serialized intoserializeToString(), which returns the XML equivalent of the document.saveXML() represents a function that would then save the serialized string.
Specifications
| Specification |
|---|
| HTML> # dom-xmlserializer-constructor> |