sam
sam

Reputation: 10064

Get all children of parent identified by a specific atribute value using xpath

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>

Upvotes: 1

Views: 91

Answers (1)

Daniel Mensing
Daniel Mensing

Reputation: 964

You can do this, with a fixed value like this:

/a/b[@ref='123']/c

Upvotes: 2

Related Questions