XML to JSON
Try it interactively →POST /api/xml-to-jsonParse XML to JSON. Attributes prefixed with `@_`, configurable type-coercion for numeric/boolean leaves, whitespace-trimming.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| xml* | string | — | XML source. |
| preserveAttributes | boolean | true | Include attributes (prefixed `@_`) in output. |
| parseValues | boolean | false | Coerce numeric/boolean leaves to typed JS values. |
| trimValues | boolean | true | Trim whitespace from text nodes. |
Response
Modes: json. Cache: yes (24h TTL).
Code samples
Built from the simple example.
curl -X POST https://api.xtract.bot/api/xml-to-json \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"xml": "<?xml version=\"1.0\"?><note priority=\"high\"><to>Tove</to><from>Jani</from><body>Don't forget!</body></note>"
}'