# XML to JSON (`convert.xml_to_json`)

Parse well-formed XML into JSON: attributes become @name, text becomes #text, repeated elements become arrays.

- **Route:** `POST /v1/run/convert.xml_to_json`
- **Price:** $0.0002 per request ($0.20 per 1,000) · `cost_usd` on every response
- **Source:** GetAllAPIs compute (`compute`) · failover: no
- **Measured latency:** p50 6 ms · p95 6 ms · p99 6 ms (1 calls, 30d)
- **Heavy response:** no

## Input

| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| `xml` | string | yes |  | XML document |

## Output (`output` in the run envelope)

| Field | Meaning |
|---|---|
| `root` | Name of the root element. |
| `json` | The document as JSON. |

## Example

```bash
curl -s -X POST https://getallapis.com/v1/run/convert.xml_to_json \
  -H "Authorization: Bearer $GETALLAPIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"xml":"<order id=\"7\"><item sku=\"a1\">Widget</item><item sku=\"b2\">Gadget</item><total>21.5</total></order>"}'
```

```python
from getallapis_client import Client
client = Client()  # reads GETALLAPIS_API_KEY
result = client.run('convert.xml_to_json', {'xml': '<order id="7"><item sku="a1">Widget</item><item sku="b2">Gadget</item><total>21.5</total></order>'})
print(result['cost_usd'], result['output'])
```

```bash
getallapis run convert.xml_to_json '{"xml":"<order id=\"7\"><item sku=\"a1\">Widget</item><item sku=\"b2\">Gadget</item><total>21.5</total></order>"}'
```

Quote first (free, validates input): `POST /v1/quote/convert.xml_to_json` with the same body.
