Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想通过 2 个条件选择节点元素。例如:
<bbb> <aaa name="param1">val1</aaa> <aaa name="param2">val2</aaa> <aaa name="param3">val3</aaa> </bbb>
我想获取元素 aaa,属性名称 =“param1”。最好的方法是什么?
假设您已经使用 Dom4j 解析了文档,那么...
Document doc = ... Node node = doc.selectSingleNode("//aaa[@name='param1']");
... 应该管用。该node变量应包含您想要的元素。
node