Reputation: 51
I would like to know about how to retrieve corresponding xpaths when we input an xml file in java with eclipse platform.
For example,
<document>
<name>xml file</name>
<size>12 kb</size>
</document>
the result is:
/document
/document/name
/document/size
Upvotes: 0
Views: 3153
Reputation: 2792
You can have this feature over firefox with the plugin firebug:
Upvotes: 3
Reputation: 39606
I'm going to assume that you (or someone else who finds this question) is looking to report a valid XPath for a specific node in a DOM. I use this quite a bit for logging, and the Practical XML library has a couple of methods to do this: DomUtil.getAbsolutePath() and DomUtil.getPath(). (disclaimer: I am the maintainer of this library).
If you're looking for something else, please try to explain yourself better.
Upvotes: 0
Reputation: 8778
Well I don't think there is a way for a computer to list all possible xpath expressions (unless you really intend to list the combinations of your expressions as well). Thus, I assume your question is "How to list the paths to all the nodes of an xml file". With this assumption I would use DOM to parse the file, then iterate to each node and print the path from the root to that note.
Upvotes: 1