Express XPath as an expression tree

Posted by 47d_ on Stack Overflow See other posts from Stack Overflow or by 47d_
Published on 2010-05-18T21:18:13Z Indexed on 2010/05/18 21:20 UTC
Read the original article Hit count: 195

Filed under:
|
|

If I have an XPath query like

NodeA/NodeB[@WIDTH and not(@WIDTH="20")] | NodeC[@WIDTH and not(@WIDTH="20")]/NodeD

Is there any API available to visualize this XPath query as a stack of atomic expressions, something like (following is generic)

  1. Get results of NodeA, call it "first set"
  2. Get results of NodeB from "first set"
  3. Filter where [@WIDTH and not(@WIDTH="20")]
  4. Filter NodeD, call this "node d for B"
  5. Get results of NodeC from "first set"
  6. Filter where [@WIDTH and not(@WIDTH="20")]
  7. Filter NodeD, call this "node d for C"
  8. Combine "node d for B" and "node d for C"

I am trying to see if we can convert the XPath expression into custom expression which is close to english and vice versa.

If no API is available, what would be the best approach? Thanks in advance.

© Stack Overflow or respective owner

Related posts about xpath

Related posts about expression