var getdata='<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns0:HelpDesk_Submit_ServiceResponse xmlns:ns0="urn:COL_HPD_IncidentInterface_Create_WS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ns0:Incident_num>INC123123</ns0:Incident_num></ns0:HelpDesk_Submit_ServiceResponse></soapenv:Body></soapenv:Envelope>' var xmlDoc = new XMLDocument2(); xmlDoc.parseXML(getdata); var getNum= xmlDoc.getNodeText("//ns0:Incident_num"); gs.print(getNum);
Output:
How to parse soap XML response in ServiceNow
Working Code Edited question August 8, 2023