XPATH expressions in MSXML selectNodes() function are evaluated on the whole DOM tree

The selectNodes() function available in the Microsoft XML (MSXML) API evaluates the XPATH expressions supplied as the argument in the context of the whole DOM tree to which the DOM node belongs, not just the node on which the selectNodes function was executed. For example, if you use the following code …
set firstDiv = document.selectSingleNode("//div")
set paraList = firstDiv.selectNodes("//p")
… the paraList will contain the list of all paragraphs in the whole document, not just the list of paragraphs in the DIV on which the selectNodes call was executed.

2 comments:

Anonymous said...

Sure

set paraList = firstDiv.selectNodes("p")

Ivan Pepelnjak said...

Sure. I know that.

I probably wanted to get all the P nodes in DIV. I could have used the descendant:: axis, but thought the XPATH expression would be evaluated in the context of the node on which it was called.

Post a Comment