Is there a way to iterate xml node in the relevance script?

(imported topic written by SystemAdmin)

say i have the following XML node:

if i want to check the operation = 053 and state=4 AND operation = 061 and state=4 AND… then (write something OK) else (write something not ok)

how do i do it? been cracking my head to complete this…

(imported comment written by NoahSalzman)

This is ugly but it seems to work:

q: ((exists child nodes whose (exists node values whose (it is “4”) of attributes of it and exists node values whose (it is “061”) of attributes of it) of it) AND (exists child nodes whose (exists node values whose (it is “4”) of attributes of it and exists node values whose (it is “053”) of attributes of it) of it)) of child node of xml document of file “c:\test.xml”

A: True

Which leads you to:

q: if (((exists child node whose (exists node values whose (it is “4”) of attributes of it and exists node values whose (it is “061”) of attributes of it) of it) AND (exists child node whose (exists node values whose (it is “4”) of attributes of it and exists node values whose (it is “053”) of attributes of it) of it)) of child node of xml document of file “c:\test.xml”) then “foo” else “bar”

A: foo

Note that this will likely fail if your source XML is more complicated than your example. In particular, note that “child node of xml document” assumes that there is one child node of and no other nodes.

(imported comment written by MattBoyd)

Here’s another way that uses xpath to check the attribute values:

if (exists xpaths “//Root/RC” of xml document of file “C:\test.xml”) then (“Yep”) else (“Nah”)

(imported comment written by jeremylam)

Or you can use XPath:

exists xml document

whose

(

(

(

exists xpath “RC” of it

)

AND

(

exists xpath “RC” of it

)

)

of child node of it

)

of file “testxml.xml”