Scenario
An integration partner returns XML as one dense line, and your parser fails with something like mismatched tag at line 1, column 58 — a location that is useless when the whole document is line 1. Minified XML makes every structural question (is <item> inside <items>? did an attribute lose its quote?) unanswerable by eye. Pretty-print it first; most "XML bugs" become visible the moment the nesting is indented.
Broken input
<order><id>42</id><items><item sku="A1">Widget</item></items></order>
Goal
Use XML Formatter & Validator to format and validate the XML without losing attributes or text nodes. A readable tree turns the parser's line-1-column-58 complaint into a specific element you can point at.
Tool sequence
- Open XML Formatter & Validator.
- Paste the single-line response exactly as the API returned it, before any manual editing.
- Format it and let the validator run — a well-formedness error here means the payload is broken at the source, not in your parser.
- Read the indented tree:
orderwrapsidanditems,itemswraps oneitem, and thesku="A1"attribute is still attached to the item element. - If the payload must become JSON for downstream code, convert it only after this validation pass, and pretty-print the result with JSON Formatter.
Checkpoint output
<order>
<id>42</id>
<items>
<item sku="A1">Widget</item>
</items>
</order>
The structure is valid and readable: nesting is intact and the sku attribute survived formatting. Whatever broke the parser, it was not this document's shape.
Common mistakes
- Converting XML to JSON before confirming the XML is well-formed — the converter's error will be even vaguer than the parser's.
- Dropping attributes while manually reformatting, then hunting a "data loss" bug you introduced yourself.
- Fixing the tag the error message names without re-validating the whole tree; one unclosed tag often cascades into several phantom errors.
- Trusting indentation someone added by hand — pretty whitespace does not mean valid nesting.
Related tools and lessons
- HTML Formatter - Format or minify HTML code.
- YAML ↔ JSON Converter - Convert YAML to JSON and JSON to YAML.
- JSON Formatter - Format, minify, and filter JSON by keys.
- Related lesson: Make Minified HTML Readable Before Debugging
- Related lesson: Convert a YAML Config Into JSON for an API