bontade
bontade

Reputation: 3224

dom4j - select node by 2 conditions

I want to select node element by 2 conditions. For example:

<bbb>
    <aaa name="param1">val1</aaa>
    <aaa name="param2">val2</aaa>
    <aaa name="param3">val3</aaa>
</bbb>

I want to get element aaa, with attribute name = "param1". What's the best way to do that?

Upvotes: 0

Views: 1004

Answers (1)

skaffman
skaffman

Reputation: 403441

Assuming you've already parsed the document with Dom4j, then...

Document doc = ...
Node node = doc.selectSingleNode("//aaa[@name='param1']");

... should work. The node variable should contain your desired element.

Upvotes: 1

Related Questions