0
有没有人知道如何在使用dom4j元素时自动获取带密钥的xpath?使用dom4j创建带密钥的xpath
让我解释一下:
考虑下面的XML我创建了一个dom4j的文档。
<response>
<installation>
<id>0001</cid>
<code>0000</code>
</installation>
<installation>
<id>0002</cid>
<code>0078</code>
</installation>
</response>
通过文档循环我可以创建使用element.getUniquePath()
或element.getPath()
/response/installation[1]/code
or
/response/installation/code
到目前为止好每一个元素的XPath,但足以不太好。由于对象的顺序无法预先知道,所以我想在我的xpath中使用键。
/response/installation[id=0001]/code
现在我的问题是,如果有人知道如何做到这一点。
在此先感谢。