We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

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

What's the error description you're gettin?


fredi_fr
ServiceNow Employee

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