Serialize a DOM Document (or any Node) back to a string.
encoding is accepted for parity with Python's doc.toxml(encoding=...)
and is currently advisory: @xmldom always emits UTF-16 JS strings and
leaves byte-encoding to the caller (write the result with fs.writeFile(..., 'utf8')
unless you have a reason to do otherwise). When encoding is supplied
we prepend an XML declaration that names it, like Python does — and when
the document already carries a declaration, its encoding pseudo-attribute
is rewritten to name the requested encoding, since the returned string is
what the caller will store or re-parse as that encoding.
Serialize a DOM
Document(or anyNode) back to a string.encodingis accepted for parity with Python'sdoc.toxml(encoding=...)and is currently advisory:@xmldomalways emits UTF-16 JS strings and leaves byte-encoding to the caller (write the result withfs.writeFile(..., 'utf8')unless you have a reason to do otherwise). Whenencodingis supplied we prepend an XML declaration that names it, like Python does — and when the document already carries a declaration, its encoding pseudo-attribute is rewritten to name the requested encoding, since the returned string is what the caller will store or re-parse as that encoding.