v151 · web platform · parsing

DOMParser Playground

Chrome 151 replaces the C++ XML parser behind DOMParser with a memory-safe Rust implementation for non-XSLT scenarios. The web-facing contract is unchanged, and this playground exercises it live: feed DOMParser.parseFromString(…, "application/xml") any document and inspect the resulting DOM tree — or the <parsererror> the well-formedness rules produce.

ready

    

how well-formedness surfaces

Unlike the lenient HTML parser, the XML parser is strict: a single missing close tag, a mismatched element, or a bare & makes the whole document not well-formed. DOMParser never throws for XML — instead it returns a document whose root is a <parsererror> element you detect like this:

const doc = new DOMParser().parseFromString(source, "application/xml");
const error = doc.querySelector("parsererror");
if (error) {
  // not well-formed — error.textContent describes where
} else {
  // valid XML DOM — walk doc.documentElement
}

The Rust rewrite keeps this behaviour byte-for-byte; it just removes a class of memory-safety bugs from the code path that produces it. Everything you see here is your browser's real parser output.

see also

references