Does anybody know how to automagically get xpath with keys when using dom4j elements?
Let me explain:
Given the following xml I have created a dom4j document.
<response>
<installation>
<id>0001</cid>
<code>0000</code>
</installation>
<installation>
<id>0002</cid>
<code>0078</code>
</installation>
</response>
Looping through the document I can create an xpath for each element using element.getUniquePath()
or element.getPath()
/response/installation[1]/code
or
/response/installation/code
So far so good, but not quite good enough. Since the order of the objects can never be know in advance I would like to use key in my xpath.
/response/installation[id=0001]/code
Now my question is if anybody out there knows how to do this.
Thanks in advance.