Timon Doo
Timon Doo

Reputation: 153

Select Title Element with certain criteria XMLPath

Given an XML structure like so:

<CATALOG>
  <Computer ID="1">
    <TITLE>Deep Blue</TITLE>
    <COUNTRY>USA</COUNTRY>
    <COMPANY>No</COMPANY>
  </Computer>
  <Computer ID="2">
    <TITLE>Linux</TITLE>
    <COUNTRY>UK</COUNTRY>
    <AVAILABILITY>Yes</AVAILABILITY>
  </Computer>
</CATALOG>

I want to get the TITLE Element of the Computer which is from the COUNTRY USA. With */[text() = 'USA'] i get all Elements which contain the USA Text but not the TITLE. Thanks for your help

Edit: The sample above is just a small snippet of the whole code

Upvotes: 0

Views: 38

Answers (1)

Yitzhak Khabinsky
Yitzhak Khabinsky

Reputation: 22177

Here is your XPath expression.

XPath

/CATALOG/Computer[COUNTRY='USA']/TITLE

Upvotes: 1

Related Questions