v147 · Security · Rust Parser Demo
Rust Parser Demo
Parses XML through DOMParser — the same API, now backed by a Rust parser in Chrome 147. Input and output are identical; only the underlying implementation changed.
Chrome 147 uses Rust to parse XML in DOMParser, XMLHttpRequest, and fetch. The API surface is completely unchanged — you write the same JavaScript and get the same DOM tree. This demo shows the parser's behaviour on valid XML, malformed XML, and edge cases.
XML parser
Input XML
Parsed output
(click Parse)
code
// DOMParser.parseFromString — unchanged API, Rust engine in Chrome 147
const parser = new DOMParser();
const doc = parser.parseFromString(xmlString, 'application/xml');
// Check for parse errors (XML is strict — errors return an error document)
const parseError = doc.querySelector('parsererror');
if (parseError) {
console.error('Parse failed:', parseError.textContent);
} else {
// Query the result like any DOM document
const items = doc.querySelectorAll('item');
items.forEach(item => {
const name = item.querySelector('name')?.textContent;
const price = item.querySelector('price')?.textContent;
console.log(name, price);
});
}
// Serialize back to string
const serializer = new XMLSerializer();
const xmlString = serializer.serializeToString(doc);
see also
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗