Links

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.
1
let xml := "<?xml version=""1.0"" encoding=""UTF-8""?>
2
<note>
3
<to>Captain America</to>
4
<from>Ninox</from>
5
<heading>Save the world!</heading>
6
<body>Hey Cap, please save the world!</body>
7
</note>";
8
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 modified 1yr ago