v151 · web platform · parsing

Namespaces Explorer

XML namespaces are the reason a single document can mix SVG, XHTML, and custom vocabularies unambiguously. The parser resolves each element's prefix to a namespace URI. This tool parses namespaced XML with DOMParser and shows the real namespaceURI, prefix, and localName the browser assigns — plus a live getElementsByTagNameNS query.

ready

resolved elements

nodeName (qualified)prefixlocalNamenamespaceURI
press “Parse”

namespace-aware query

Run a query to count matching elements.

why namespaces need a real parser

Namespace resolution is not string matching — a prefix like svg: is just a local alias bound by an xmlns:svg declaration that can be redeclared at any depth. The parser tracks that scope so that two elements written with different prefixes but the same URI compare equal, and the same prefix bound to different URIs does not:

const doc = new DOMParser().parseFromString(xml, "application/xml");

// Query by namespace URI + local name, independent of prefix
const circles = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "circle");

// Each element exposes the resolved binding
el.namespaceURI;  // "http://www.w3.org/2000/svg"
el.prefix;        // "svg"  (or null for the default namespace)
el.localName;     // "circle"

The Rust rewrite keeps this resolution identical — it is the same well-tested contract, on a memory-safe code path.

see also

references