Java Business RIA redefined!
The moose likes XML and Related Technologies and the fly likes XPATH - selection based on multiple attribute values The Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "XPATH - selection based on multiple attribute values" Watch "XPATH - selection based on multiple attribute values" New topic
Author

XPATH - selection based on multiple attribute values

Nisha Soorya
Greenhorn

Joined: Dec 01, 2005
Posts: 11
Hello Experts,

I'm stuck with trying to construct an Xpath expression. I have an xml document resembling the following:

<root>
<record id="1">
<field id="220" value="Red" />
<field id="221" value="Small" />
<field id="222" value="25" />
</record>
<record id="2">
<field id="220" value="Red" />
<field id="221" value="Large" />
<field id="222" value="50" />
</record>
</root>

I want to return the record where the value of the field with id=220 is "Red" AND where the value of the field with id="221" is "Large".

In other words, I want to find a parent node based on the attributes of 2 of its element children.

Can you help?

Nisha
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 7901
My guess:
Nisha Soorya
Greenhorn

Joined: Dec 01, 2005
Posts: 11
That did work exactly the way I wanted. Sorry for being late to say THANK YOU. I was excited when it worked.
 
aspose file troubles
 
subject: XPATH - selection based on multiple attribute values
 
The most intelligent Java IDE