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:

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

JSON equivalent (compacted):

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