javascriptjqueryxmlgoogle-apps-scriptgoogle-caja

parseXML returns INVALID XML in Google Apps Script


In a Javascript file in Google Apps Script (not Google Script but a Caja-ed Javascript), I want to parse a string to an XML document. Outside of GAS this works:

$.parseXML("<root><message>Hello World</message></root>");

But in a GS file:

<script type="text/javascript">
var xml = $.parseXML("<root><message>Hello World</message></root>");
alert(xml);
</script>

the parseXML claims my xml is invalid. I assume this is something weird with whatever pre-processing GAS does to my JavaScript (Caja?). Is there a solution? I've tried with Jquery 1.11 and 1.9.0


Solution

  • Unfortunately, Caja does not support XML DOM.

    If anyone is interested in what it would take to contribute such support, the main additions to the DOM taming component which would be needed are: