简体   繁体   中英

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>

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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