/
xml

xml

Functions

[string]	asJSON([string] xml) // convert an xml string to json string

Examples

Simple convert

Convert an xml string  to a json string and print it

var myXml="<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>";
print(xml.asJSON(myXml));

Output:

{"note":{"heading":"Reminder","from":"Jani","to":"Tove","body":"Don't forget me this weekend!"}} 


Load remotely,  convert and use data

Load an xml from W3schools convert it to json object and print a table based on that

var myXml=http.get("https://www.w3schools.com/XML/note.xml");
var myJson=JSON.parse(xml.asJSON(myXml));

var from=myJson.note.from;
var to=myJson.note.to;
out.table(["from","to"],[[from,to]]);

Output:

fromto
JaniTove

Related content

Get Started
More like this
2.Hello World, Using JavaScript File Runner macro
2.Hello World, Using JavaScript File Runner macro
More like this
1.Hello World, Using JavaScript Runner macro
1.Hello World, Using JavaScript Runner macro
More like this
3.First dynamic page
3.First dynamic page
More like this
Confluence Dynamic Pages Home
Confluence Dynamic Pages Home
More like this
Confluence Dynamic Pages
Confluence Dynamic Pages
More like this