是否可以在循环内访问父节点?
我有一个像这样的循环:
for $a in local:distinct-nodes($x/input/book[@stat = 'ok'])
let $b:=string($a/../input/@docid)
这返回一个空字符串($b 为空)。所以,我想知道在这种情况下如何访问父节点。我真的不想从 root (//xxxx) 访问它,因为 XML 文件非常大。
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 file is quite large.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这就是应该生产的。
所有 $a 节点都是
book
元素。input
元素应该是
input/input
元素,但很可能input
元素没有input
子元素。你想要的是:
Yes, this is what should be produced.
All $a nodes are
book
elements.are
input
elementsshould be
input/input
elements, but most probablyinput
elements dont haveinput
children.What you want is: