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" }, "first": { "_text": "John" }, "lastname": { "_text": "Doe" } } }

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