views:

55

answers:

2

Hi,

I'd like to search an xml doc (or rather Element with sub elements) for a string. It needs to be an exact match.

Here's a sample of the xml

<Car>
 <Make value="German\Opel"/>
 <Make value="German\Benz"/>
 <Make value="Japanese\Nissan"/>
</Car>
+2  A: 

Assuming you want to return the find the element baset on the string, you can use the following xpath with your example:

/Car/Make[@value = 'German\Opel']

The part in the square brackets is called a predicate and acts as a filter to the expression before.

Obalix
A: 

Further to Obalix's answer, there is a xPath tutorial here that would be quite helpful in answering future questions about building xPath queries.

http://www.w3schools.com/xpath/default.asp

Enjoy

Trevor Sullivan