Some services still send and expect XML — e-invoicing networks, older shipping and accounting systems, SOAP APIs. The XML steps turn XML into fields you can drag into later steps, and turn fields back into XML for a request. Neither needs a connection.
Who can do this
Workspace Admins and Editors, on every plan.
The steps
| Step | What it does |
|---|---|
| Convert XML to JSON | Reads XML into fields later steps can use, element by element. |
| Convert JSON to XML | Writes fields as XML, under a root element. |
Steps
- Select + after the step that gives the XML or the fields. In the step picker, open Utilities, select XML — No connection needed — then the step. Or search XML.
- In XML (or JSON), put the value — such as
{{ $json.body }}from a webhook,{{ $json.invoice }}for one field that holds an object, or{{ $json }}for the whole item. - For Convert JSON to XML, optionally type the Root element — for example
Invoice. Empty: the JSON's one top field, else root. - In Put the result in, keep the suggested field name or type your own. The item's other fields are kept.
- Select Run this step, then check Output.
Output
Convert XML to JSON gives the fields under json by default, starting with the root element: <Invoice id="INV-1042"><Total>1499</Total></Invoice> becomes {"Invoice": {"@id": "INV-1042", "Total": "1499"}}. Attributes come back as @ and their name. An element that appears more than once becomes a list. Text inside an element that also has attributes or child elements is under #text. An empty element is empty.
Convert JSON to XML gives the XML text under xml by default, indented, without an <?xml …?> line at the top. Keys that start with @ become attributes, #text becomes the element's text, and a list becomes the same element repeated.
Every other field on the item is kept; a field already called that is replaced.
Good to know
- DTDs and external entities are refused. XML that has a
<!DOCTYPE …>part is stopped, because a DTD can make a file read others or call out; ordinary XML never needs one. Comments are dropped. - Every value arrives as text. Use Set / Edit Fields to make a number a number.
- An element that appears once is not a list. An order with one line gives an object where an order with three gives a list, and Split Out stops on the object — check for it with an IF first when an order can have just one line.
- Names keep their prefix. In XML with namespaces, such as UBL e-invoices,
<cbc:ID>comes back ascbc:ID. - The root element. With Root element empty, JSON with exactly one top field —
{"Invoice": {…}}— uses that field as the root; anything else is wrapped in<root>. A name that is not allowed in XML, such as one with a space, is written in XML's escaped form. - To read an XML file, read it into text first with CSV and spreadsheets › Read a JSON or text file, with Read it as set to Text, then put its result in XML. Dragging the file itself into XML gives only its name.
- It runs once per item.
If something goes wrong
| What the run says | Why | What to do |
|---|---|---|
| The XML can't be read: … | The text is not well-formed XML; the rest says where. | Check the step's Input; the sender may have sent an error page. |
| The XML has a DTD, which this step refuses — a DTD can make a file read others or call out. Remove the <!DOCTYPE …> part. | The XML has a <!DOCTYPE with a DTD. |
Ask the sender for XML without one, or take the part out with the Text tool's Replace first. |
| XML is empty when the step ran — an earlier step may not have given the value it names. (or JSON) | The box names a value the item does not have. | Check the step's Input; correct the value in {{ }}. |
| JSON is text that is not JSON. Choose a field that holds an object. | JSON holds plain text. | Choose a field that holds an object, or JSON text. |