Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Parsing XML and not able to get the node value I want

Jason Stephens
Kilo Guru

Hello Everyone!

I am trying to parse a value out of an XML response, and I can't seem to get it.   The response is returning correctly to me as needed (verifying using tostring() as you see below), but when I try to grab the "RequesterID" value that I need, I always get a return value of "null".   Code Snippet below as to how I'm trying to grab it, and I have also attached the response.     Pretty sure this is something simple, but I'm missing it...

var xmlDoc = new XMLDocument2();  

xmlDoc.parseXML(responseBody);

//gs.info(xmlDoc.toString());

gs.info(xmlDoc.getNodeText("//RequesterID"));

Thanks for any help!

Jason

10 REPLIES 10

Hi Jason,



Alternatively, may be converting the XML to JSON unless it is a bigger payload could be beneficial as pointed by the post below:-


Processing Inbound XML - Scoped Application Strategy