简体   繁体   English

XPath | 路径表达式

[英]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? 上面的XML的“ select [cities] where [name] ='Orange'”的等效XPath表达式是什么?

Edit 07/27/09 00:29 AM PST: 编辑太平洋标准时间07/27/09 00:29:

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

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

方括号[../name="Orange"]的谓词大致等同于where子句。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM