开发者

Is it possible to access the parent node inside the loop?

I have a loop like this:

for $a in local:distinct-nodes($x/input/book[@stat = 'ok'])
let $b:=string($a/../input/@docid)

This returns an empty string($b is empty). So, I am wondering how I can access the parent node in this situation. I do not really want to access it from root (//xxxx) cause the XML开发者_C百科 file is quite large.


I have a loop like this:

 for $a in local:distinct-nodes($x/input/book[@stat = 'ok']) 
 let $b:=string($a/../input/@docid) 

This returns an empty string($b is empty).

Yes, this is what should be produced.

All $a nodes are book elements.

$a/..  

are input elements

$a/../input

should be input/input elements, but most probably input elements dont have input children.

What you want is:

$a/../@docid
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜