Convert XML to JSON with Apps Script

The XMLService class of Google Apps Scripts lets you parse and navigate the nodes of any XML file. You can also convert the XML to JSON and access the XML nodes though the simpler dot notation.

Unlike the deprecated XML class, the new XMLService class doesn’t allow lenient parsing and hence may not be parse the HTML DOM structure since it may not be well formed.