Evaluating XPath Commands with java
Hi, I have an XML document like this
<root> <cert id="1"> </cert> <cert id="2"> </cert> <cert id="3"> </cert> </root> Now I get a request and want to select a certificate with id 2 and I want to return it to the function. What is the best way to do this? I was thinking about XPAth Expression, how can I use them in java? What will be the best result (return value).
Thank you in advance
Sebastian
Check out this article in the Java XPath API. It includes information on how to use the API, plus an example of using XPath itself.
Your XPath expression in this scenario will be
/root/cert[@id='2']