开发者

Using the result of an XPATH in another xpath expression

开发者 https://www.devze.com 2023-03-27 06:42 出处:网络
I have a XML like the below. Here I wanted to slect the attribut开发者_如何学JAVAe value of node b which is 23 take that value and go down the xml and pick the node j of node f which has the id value

I have a XML like the below. Here I wanted to slect the attribut开发者_如何学JAVAe value of node b which is 23 take that value and go down the xml and pick the node j of node f which has the id value 23. Can this be achieved in a single xpath expression.

I am using JAXP for xml processing

<a>
  <b id="23"/>
  <c></c>
  <d></d>
  <e>
    <f id="23">
       <i>123</i>
       <j>234</j>
    <f>
    <f id="24">
       <i>345</i>
       <j>456</j>
    <f>
    <f id="25">
       <i>678</i>
       <j>567</j>
    <f>
  </e>
</a>


How about this?

//f[ @id = //b[1]/@id ]/j
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号