XPATH problem with dom4j

房东的猫 提交于 2019-12-02 13:24:39

to select the three values, use:

//name[@time='555555']/element1/value

If that returns null as well, there may be a default namespace involved and that means you need to show your entire XML.

XPath is flexible, if you want you can express the same like this:

//value[ancestor::name[1]/@time='555555']

The XPath that you are using is looking for a time attribute equal to 555555 on element1. However, your time attributes are on the name nodes.

You could go either the way Tomalak suggested, or change it to:

//element1[../@time='555555']

This is looking for an element1 node with a parent who has a time attribute equal to 555555.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!