1

Is there a way you can get all get all children of a parent with a specific attribute value using xpath, for instance if i wanted to get all the children of the first <b> below i could write

/a/b[0]/c

but is there a way i can do that using a fixed attribute value, something like

/a/b=ref:123/c

so that i wouldn't matter were in the feed that instance of <b> would be

XML

    <a>
      <b ref="123"></b>
        <c></c>
        <c></c>
        <c></c>
      <b></b>

      <b ref="456"></b>
        <c></c>
        <c></c>
        <c></c>
      <b></b
    </a>
4

1 回答 1

2

您可以使用如下固定值执行此操作:

/a/b[@ref='123']/c
于 2013-04-30T14:04:53.430 回答