0

Suppose I have an XML:

<as>
  <a>
    <name>xxx</name>
    <data>xxx-data</data>
  </a>
  <a>
    <name>yyy</name>
    <data>yyy-data</data>
  </a>
  <a>
    <name>zzz</name>
    <data>zzz-data</data>
  </a>
</as>

Now I would like to write an XPath to select the data text of the element a with the name text xxx. This Xpath should return xxx-data. How can I do that?

4

2 回答 2

2

在级别上使用谓词a选择 right a,然后取其data子项:

/as/a[name = 'xxx']/data
于 2012-12-04T14:49:39.510 回答
1

这样的事情应该做:

/as/a[name="xxx"]/data
于 2012-12-04T14:52:00.293 回答