gs.xmlToJSON method causes uncatchable XML parsing error Issue Trigger a SOAP call and use gs.xmlToJSON to process the input with numeric character references. This generates an uncatchable XML parsing error but the XML passes parsing and validation by GlideXMLUtil.validateXML and XMLDocument2.parseXML works as expected Sample code to test: // **** START OF CODEvar xmlStr = "<x> </x>";gs.print('GlideXMLUtil.validateXML=' + GlideXMLUtil.validateXML(xmlStr, true, false));var xmlDoc = new XMLDocument2();xmlDoc.setNamespaceAware(true);xmlDoc.parseXML(xmlStr);gs.print('about to try xmlDoc.getDocumentElement()');var test1 = xmlDoc.getDocumentElement();gs.print('about to try gs.xmlToJSON(xmlStr)');var test2 = gs.xmlToJSON(xmlStr);gs.print('got passed gs.xmlToJSON(xmlStr) without a javascript exception being thrown');// **** END OF CODE Note: You can also run this script in the background and notice the following exception: Unable to convert xml to json: org.json.JSONException: Missing ';' in XML entity: & at character 5 of <x> </x>: org.json.JSONTokener.syntaxError(JSONTokener.java:448)org.json.XMLTokener.nextEntity(XMLTokener.java:136)org.json.XMLTokener.nextContent(XMLTokener.java:111)org.json.XML.parse(XML.java:213)CauseThis is working as expected; changing the long-existing behavior of the "xmlToJSON" method would be an enhancement request. ResolutionThe workaround is to pre-process the XML input before passing to gs.xmlToJSON. Solution 1 In the mentioned code, pass test1 instead of xmlstr to gs.xmlToJSON() which is a kind of pre-processing the XML input before passing to gs.xmlToJSON(). Code used: // **** START OF CODEvar xmlStr = "<x> </x>";gs.print('GlideXMLUtil.validateXML=' + GlideXMLUtil.validateXML(xmlStr, true, false));var xmlDoc = new XMLDocument2();xmlDoc.setNamespaceAware(true);xmlDoc.parseXML(xmlStr);gs.print('about to try xmlDoc.getDocumentElement()');var test1 = xmlDoc.getDocumentElement();gs.print('about to try gs.xmlToJSON(xmlStr)');var test2 = gs.xmlToJSON(test1);gs.print('got passed gs.xmlToJSON(xmlStr) without a javascript exception being thrown');// **** END OF CODE Result: *** Script: GlideXMLUtil.validateXML=null*** Script: about to try xmlDoc.getDocumentElement()*** Script: about to try gs.xmlToJSON(xmlStr)*** Script: got passed gs.xmlToJSON(xmlStr) without a javascript exception being thrown Note there is no exception in the result Solution 2 (if you want to alter the input) The "&" in the object named "xmlstr" in the code above needs to be "&" (more information: xml decoding issue in json org.json.JSONException: Missing ';' in XML entity)Changing var xmlStr = "<x> </x>"; to either one of the following works var xmlStr = "<x>&#x20;</x>";var xmlStr = "<x><![CDATA[ \]]></x>";