XML to JSON
Turn XML into JSON, keeping attributes (as @attr), handling CDATA and typing values.
Pay by wallet (x402)
xml-to-json Example
Example answer
{
"json": "test",
"root_element": "root",
"element_count": 0,
"attributes_preserved": false
} Inputs
| Field | Type | Required | What it is |
|---|---|---|---|
xml_string | string | Yes | — |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
json | object | Always (present in every successful answer) |
root_element | string | Always (present in every successful answer) |
element_count | integer | Always (present in every successful answer) |
attributes_preserved | boolean | Always (present in every successful answer) |
How to call it
The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.
# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
-H "Authorization: Bearer $STRALE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"capability_slug": "xml-to-json",
"inputs": {
"xml_string": "<root><item>value</item><count>42</count></root>"
},
"max_price_cents": 3
}' {
"tool": "strale_execute",
"arguments": {
"slug": "xml-to-json",
"inputs": {
"xml_string": "<root><item>value</item><count>42</count></root>"
},
"max_price_cents": 3
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "xml-to-json",
inputs: {
"xml_string": "<root><item>value</item><count>42</count></root>"
},
max_price_cents: 3,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="xml-to-json",
inputs={
"xml_string": "<root><item>value</item><count>42</count></root>",
},
max_price_cents=3,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i 'https://api.strale.io/x402/v2/xml-to-json?xml_string=%3Croot%3E%3Citem%3Evalue%3C%2Fitem%3E%3Ccount%3E42%3C%2Fcount%3E%3C%2Froot%3E' Limitations
Mixed content can lose its text ordering
Converts standard XML — XML with mixed content (text interleaved with elements) may lose text ordering during conversion
What to do instead: For mixed-content XML, use a streaming parser that preserves text node positions
Related tools
- Address Parser €0.05
- Company Industry Classification €0.05
- Company Name Match €0.02
- Credit Score Band €0.02
- CSV Cleaner €0.02
- CSV to JSON €0.02