parseXML

To convert an XML string to a JSON object

This function converts an XML string to a JSON object. The function is of particular interest for connections to external services via API and the processing of corresponding data.

XML is beside JSON a common format to exchange data over the internet.

Syntax

parseXML(string)

Return

JSON

Examples

parseXML(xml) To convert an XML string to a JSON object. An invalid string will return a parse error.

We convert an XML string to a JSON object, which contains a note to Captain America to hand it over to an external service, for example an email service provider.

let xml := "<?xml version=""1.0"" encoding=""UTF-8""?>
<note>
  <to>Captain America</to>
  <from>Ninox</from>
  <heading>Save the world!</heading>
  <body>Hey Cap, please save the world!</body>
</note>";
parseXML(xml)

Result:

{"note":{"to":{"@":"Captain America"},"from":{"@":"Ninox"},"heading":{"@":"Save the world!"},"body":{"@":"Hey Cap, please save the world!"}}}

See also

formatXML To convert a given JSON object into XML text, which might be optically structured

Last updated