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.

getNodes() method

jesusemelendezm
Mega Guru

Can anyone confirm if this method still can be used in Helsinkin?

I have tried exact same samples in a script include and BR not returning any value.

http://wiki.servicenow.com/index.php?title=XMLDocument_Script_Object#gsc.tab=0

xmldoc.getNodes

00000000.JPG

1 ACCEPTED SOLUTION

fredi_fr
ServiceNow Employee
ServiceNow Employee

Yes, it worked for me, with small modifications:



var xmlString = "<test>" +


                              "   <one>" +


                              "       <two att=\"xxx\">abcd1234</two>" +


                              "       <three boo=\"yah\" att=\"yyy\">1234abcd</three>" +


                              "       <two>another</two>" +


                              "   </one>" +


                              "   <number>1234</number>" +


                              "</test>";




var xmldoc = new XMLDocument(xmlString);




var nodelist = xmldoc.getNodes("//one/*"); // two, three, and two


gs.log(nodelist.getLength());


gs.log(nodelist.item(0).getNodeName());


gs.log(nodelist.item(1).getNodeName());


View solution in original post

8 REPLIES 8

What's XMLDocument2()? Is it your own script include? Doesn't seem to be OOB


fredi_fr
ServiceNow Employee
ServiceNow Employee

What's the error description you're gettin?


fredi_fr
ServiceNow Employee
ServiceNow Employee

getNodes() does not seem to be a valid API of XMLDocument2()