Skip to content
toolbelt
Back to Guides

Bridging a SOAP API to Modern Code

By ·

Updated

The integration you have to talk to speaks XML. Everything else you own speaks JSON. Here is the seam.

What is this tool?

XML to JSON converts a document into the object model your code already understands. Attributes and repeated elements need conventions, and those conventions are where surprises live.

How it works

The document is parsed to a tree, then walked into plain objects. Attributes are kept under a predictable key, and repeated sibling elements become arrays rather than overwriting each other.

Example

<user id="42"><name>Ada</name><tag>a</tag><tag>b</tag></user>

becomes
{
  "user": {
    "@id": "42",
    "name": "Ada",
    "tag": ["a", "b"]
  }
}

When to use it

Wrapping an old API for a new frontend. Making an XML export usable in a test fixture. Inspecting a feed without writing a parser.

Optimization Tips

Single vs repeated elements are the trap. If a response has one tag today and three tomorrow, your code must handle both. Check whether the converter gives you a string or an array for a single occurrence, and normalise deliberately.

Frequently Asked Questions

How are attributes represented?
With a prefix on the key so they cannot collide with child elements.
Why did a single tag become a string but multiple became an array?
That is the classic XML-to-JSON ambiguity. Normalise it in your code rather than assuming the shape stays constant.
What about namespaces?
Prefixes appear in the keys. Strip them after conversion if you do not need them.
Is anything lost?
Comments and processing instructions are dropped. Text formatting whitespace is normalised.

Ready to try it out?

Put this knowledge into practice with our free tool.

Go to Tool

Related tools