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
現在我的問題是,如果有人知道如何做到這一點。
在此先感謝。