JohnN
JohnN

Reputation:

XPath | path expression .Net

<?xml version="1.0" encoding="UTF-8"?>
<Country>
  <States>
    <County>
      <popularity>39</popularity>
      <name>Orange</name>
      <id>13811</id>
      <url>http://www.url.gov</url>
      <overview>Orange County Overview</overview>
      <Cities>
        <City name="City #1" size="big" population="33333"/>
        <City name="City #2" size="medium" population="2222"/>
        <City name="City #3" size="Small" population="111"/>
      </Cities>
    </County>
  </States>
</Country>

What is the equivalent XPath expression of "select [cities] where [name]='Orange'" for the XML above?

Edit 07/27/09 00:29 AM PST:

I got it! Thank you all for the advices, you are are great teachers. I was able to select all attributes from all"City" with

/Country/States/County[name='Orange']/Cities/City

Upvotes: 1

Views: 236

Answers (2)

vog
vog

Reputation: 25657

//Cities[../name="Orange"]/*

The predicate in brackets [../name="Orange"] is roughly equivalent to a where clause.

Upvotes: 1

sanxiyn
sanxiyn

Reputation: 3706

//*[name="Orange"]/Cities/*

Upvotes: 0

Related Questions