XML support

When sending a request containing a valid XML body and an application/xml or text/xml Content-Type, Mockoon will parse the XML and allow you to create body response rules or use the body and bodyRaw templating helpers. Mockoon uses the xml-js NPM package to convert the entering XML. Please note that the xml-js package converts XML into JSON in a particular way, as shown below:

Entering XML body:

<?xml version="1.0" encoding="utf-8"?> <user userID="123"> <firstname>John</firstname> <lastname>Doe</lastname> </user>

JSON equivalent (compacted):

{ "_declaration": { "_attributes": { "version": "1.0", "encoding": "utf-8" } }, "user": { "_attributes": { "userID": "123" }, "firstname": { "_text": "John" }, "lastname": { "_text": "Doe" } } }

📘 Please refer to xml-js documentation for more detail on how the XML is parsed.

🛠️ Use our XML to JSON converter to get a preview of how Mockoon will convert your XML to JSON. You can also use our XML validator to make sure your XML is valid.