The input XML string
Optional parsing options
The parsed XML
If an attribute is not name="value" or name='value', if a quoted value is not closed, if a close tag does not match its open tag, or if a close tag appears with no element open
const obj = parseXml(
`<root>
<child>text</child>
<ns:tag>content</ns:tag>
</root>`,
)
assert(obj.childNodes[0].nodeName === 'root')
assert(obj.childNodes[0].childNodes[0].nodeName === 'child')
assert(obj.childNodes[0].childNodes[0].childNodes[0].nodeValue === 'text')
assert(obj.childNodes[0].childNodes[1].nodeName === 'ns:tag')
assert(obj.childNodes[0].childNodes[1].prefix === 'ns')
assert(obj.childNodes[0].childNodes[1].localName === 'tag')
Parse XML into a JS object
The parser does not validate against a DTD or schema, and it does not check every well-formedness constraint; the errors it does report are listed below under Throws. Input cut off between tags yields the nodes parsed so far.