Xpath and qualified node names on xml dom nodes

(imported topic written by SystemAdmin)

I just encountered an xml file that’s giving me some issues. It uses qualified node names, so all of the node names follow the form prefix:localpart, and the top level nodes include schema details. A quick example file would be:

<test:Root xmlns:test=“http://www.test.com/test” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.test.com/test test.xsd”>

test:Node2

</test:Node2>

</test:Root>

If I try to use a straightforward xpath query using just the node names, I’m getting an error. The following query-

exists xpaths “/test:Root/test:Node2” of (xml document of file “C:\test.xml”)

returns the error, “The expression could not be evaluated: Windows Error: Unspecified error”

I did find a workaround by using an xpath query to look for child nodes with a given name, like so: exists xpaths “child::node()/child::node()” of (xml document of file “C:\orca\test.xml”)

Is there a way to use the more straightforward xpath query that I mentioned first, or do I just need to go with the workaround I mentioned second? I’d prefer to use the first, since it’s a bit easier to follow and implement.

(imported comment written by jessewk)

You can use the ‘selects’ inspector instead of the ‘xpaths’ inspector:

node values of child nodes of selects “/test:Root/test:Node2” of xml document of file “c:\test.xml”

1 Like