# XML

Older, stricter, and still what half of enterprise integration speaks.

## How it opens

XML parses into the document shape — one root value, browsed as a tree.

Nothing is chosen by file extension alone: every adapter scores the text itself and the highest confidence wins. When two are close enough that guessing would be a coin flip, the app asks instead of picking.

- extensions · .xml, .xsd, .svg, .rss, .plist
- media type · application/xml
- shape · document
- extra diagnostics · this adapter lints beyond what parsing reports

## Fixing

5 steps run over a XML document, in this order. Nothing is applied until you say so, and each fix can be kept or dropped on its own.

- Quote unquoted attribute values (attr=value → attr="value")
- Escape raw & and < in text content (&amp; / &lt;)
- Match closing tag case to its opener (</Items> → </items>)
- Insert missing closing tags for unclosed elements — a judgment call — excluded from safe-repair-on-paste
- Remove closing tags that never had an opener — a judgment call — excluded from safe-repair-on-paste

A judgment call can say something your document did not, so it is separated from the mechanical ones on purpose.

## Nesting

A XML value can hold another system's output — a stringified body, an escaped document. Unpack opens it in place, names the parser that opened it, and repeats until nothing parses. Pack restores the original text byte for byte rather than re-serializing from the tree.

## A sample

The document below is the fixture this adapter ships and its own tests parse — not an illustration written for this page.

```
<?xml version="1.0" encoding="UTF-8"?>
<order id="ord_8f3aa19c4d">
  <customer tier="gold">
    <name>Rin Aoyama</name>
  </customer>
  <items>
    <item><sku>BRD-OAK-002</sku><qty>1</qty></item>
  </items>
…
```

---

Canonical: https://unstringify.com/docs/xml
