Can XPath be used repeatedly, to narrow the results?



Suppose I need to select a list of nodes based on multiple criteria (title of book, subject of book, author of book, price of book...), each of which may involve selecting any of multiple values (subject is one of Thailand, Finance, History; author is one of Bob, Ted, Carol, Alice)


The resulting XPath query can be very long, and the syntax quite complicated. Instead of doing the query in a single pass, is it possible to do an initial query (only considering subject, for example), generate a list of nodes, and then apply a second XPath query, to reduce that list of nodes to a shorter list?


It appears to me the answer is no, since the selectNodes method can not be applied to an IXMLDOMNodeList object, which the initial result would be. Am I missing something? Is there a way of doing this?


[The context of the question is: A form is presented to the user, to select criteria for a report generator. The user may select one or more criteria, with varying degrees of detail. Combining all the selected criteria into a single XPath query is turning out to be quite tedious, especially since different criteria occur at different levels of the tree.]


If possible, applying the criteria iteratively would greatly reduce the complexity.


No comments:

Post a Comment