XML entity handling in API XML requests: incident response
TL;DR: Validate locally, fix the first real error, validate again (no upload).
Fix XML entity handling in API XML requests: incident response with an XML escape-first workflow and local validation (no upload).
XML escape matrix
| Character | Escape | Where it matters most |
|---|---|---|
& | & | Text nodes, attributes, URLs inside XML |
< | < | Text nodes |
> | > | Optional in text; safer in generated markup |
" | " | Attribute values |
' | ' | Attribute values |
Primary rule for this page
& -> &
Focus for this query
- Escape reserved XML characters in text/attributes.
- Keep one well-formed root and validate after each change.
- Fix the first parser error before touching downstream nodes.
CDATA vs escaping
Use escaping for normal text/attributes. Use CDATA when large literal blocks are easier to keep unchanged.
- Escaping is safest for machine-generated XML fields.
- CDATA is convenient for long snippets, but still requires clean XML structure.
- Never include raw
]]>inside CDATA without splitting/escaping.
Example
<!-- Text node -->
<title>Tom & Jerry</title>
<!-- Attribute value -->
<link href="/search?q=a&b=1" />
<!-- CDATA for rich text -->
<snippet><![CDATA[if (a < b && b > 0) { return a; }]]></snippet>
Fast fix workflow
- Find first parser error line/column.
- Replace reserved character/entity usage at that location.
- Re-validate immediately after each edit.
- Convert/export only when parser reports clean XML.
Common parser signals
- EntityRef: expecting ; — raw
&or incomplete entity. - Undefined entity — entity not declared/unsupported by parser.
- Unescaped ampersand in URL — use
&inside XML.
FAQ
Is anything uploaded to a server? No. All processing happens locally in your browser. Files are never uploaded.
What is the recommended workflow? Validate the input, fix the first real issue, validate again, then export/convert. This avoids compounding errors.
Related tools
Related guides
Privacy & Security
All processing happens locally in your browser. Files are never uploaded.
Related by intent
Closest pages and hubs to accelerate crawl discovery and first impressions.
First impression poolImpression seed hubIntent hub: runbooksTopic: xmlRelated: winner ruby base64url vs base64 runbooks api gatewayRelated: python ini comparisons incident responseRelated: winner ruby jsonwebtoken jwt signature is required runbooks qa regressionRelated: winner java jsonwebtoken jwt signature is required runbooks webhooks