Jump to content

XPath parser in Java


kgw

Recommended Posts

Hi,Is there any XPath parser written in java?What I want is: given an XPath string, let say /a/b[pred01]/axes::*/... (pred01 can be anything)it would return the steps of the XPath, ex: a, b[pred01], axes, ...or something more detailThanks,kgw

Link to comment
Share on other sites

Xercec2-j is an XML parser for JAVA. There's also JAXP from Sun themselves. This few pages article discusses different JAVA parsers. It's probably good to read as it discusses good pointers such as the Performance of each one.
Link to comment
Share on other sites

Hi boen_robot,Thanks for the article, but actually it's not what I am looking for. I am not looking for XML parser (parser to parse XML document), but rather XPath parser (to parse XPath). But I do not want the XPath parser to evaluate the XPath expression and return me XML nodes (I don't want the XPath parser to query the XML document). Rather, I want the XPath parser to return me an array or a list or tree or anything where I can go step by step. I am looking for something like this:xpath = XPathParser.parse("/a/b[P and Q]/following::*");xpath.step(1) will return axis = child, NameTest = axpath.step(2) will return axis = child, NameTest = b, predicate = P and Qpredicate can further be divided into predicate.part(1) = P, predicate.part(2) = Q, predicate.boolean() = andxpath.step(3) will return axis = following, NameTest = *Thanks,kgw

Link to comment
Share on other sites

I don't think there is such a thing. Simply because it's not something that needed. You could construct something like this yourself by using regular expressions, but I feel it's not worth the effort.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...