Document syntax
PCDATA
Parsed character data: text content that the parser scans for markup, so < and & in it have meaning and must be escaped.
The term comes from DTD content models, where #PCDATA is how an element declares that it may contain text. Outside a DTD it survives as the name for the ordinary case: characters the parser reads, resolving entity references and recognising the start of any tag it meets.
The contrast is with a CDATA section, where the same characters are taken literally. Both end up as text nodes; the difference is only in what had to be escaped to get there.
- Defined in
- XML 1.0 §3.2.2
- Category
- Document syntax
- Also written
- #PCDATA, parsed character data
Shown, not asserted
All 2 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.
Escaped markup in PCDATA arrives as characters, not as elements.
document.xml <x>a < b & c</x>expression string(/x)What the engine returns
a < b & cAn unescaped ampersand starts an entity reference, so what follows is read as a name — and the parser stops when no semicolon arrives.
document.xml <x>Ada & Lovelace</x>What the engine returns
EntityRef: expecting ';' (line 1)
What catches people out
- The characters legal in a document are constrained: most C0 control characters cannot appear in PCDATA at all, escaped or not.
- > does not strictly need escaping in content, but escaping it anyway avoids the one case where it does — the ]]> sequence.
- A DTD content model of (#PCDATA) permits text only. Adding a child element there is a validity error, not a well-formedness one.
Where it bites
A definition on its own is trivia. These are the pages where this term decides whether a document works.
- Parse errorsPCDATA invalid Char value (control character)What a control character in text content reports.
- Parse errorsUnescaped ampersand (EntityRef: expecting ';')The failure a bare < in content produces.
- ToolsXML escape & unescapeTurns arbitrary text into something safe to put in PCDATA, and back again.
Related terms
- CDATA sectionA <![CDATA[ … ]]> block whose contents are treated as literal characters, so < and & inside it start nothing.
- Text nodeA run of character data in the tree, as a node in its own right — the model a query language sees rather than the markup you wrote.
- Predefined entityOne of the five entities every XML parser knows without a declaration: &, <, >, ' and ".
- Invalid XML characterA code point XML forbids in a document at all — most of the C0 control range — which cannot be included literally or as an escape.
- Mixed contentAn element containing both text and child elements, interleaved — the model prose uses and data rarely does.
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.