v151 · web platform · parsing

Entities & CDATA

XML text is not literal: predefined entities (&amp; &lt; &gt; &quot; &apos;) and numeric character references (&#169;) expand, while <![CDATA[…]]> sections hold raw text that would otherwise need escaping. This tool parses your XML and shows the exact textContent, node type, and raw characters your browser's parser produced.

ready

documentElement.textContent (resolved)

character-by-character length

child nodes of the root

nodeTypenodeNamenodeValue / text

what the parser resolves — and what it doesn't

The five predefined entities and numeric references are expanded during parsing, so textContent gives you the decoded characters. A CDATA section becomes a distinct node (nodeType === 4) whose contents are taken verbatim — < and & inside it are literal, not markup. Custom entities declared in an internal DTD subset are a deliberate security boundary: browser DOMParser implementations do not expand externally-defined or general DTD entities, which is what stops "billion laughs" and XXE attacks. Use the last preset to observe exactly what your browser does with one.

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

// Predefined + numeric refs are already decoded here
doc.documentElement.textContent;   // e.g. "Tom & Jerry © 2026"

// CDATA content is a CDATASection node (nodeType 4), taken literally
[...doc.documentElement.childNodes].map(n => n.nodeType);

see also

references