关于 xquery 的帮助
我有一个像这样的xml结构:
<node1>
<node2 name="">
</node2>
<node2 name="">
</node2>
<node2 name="">
</node2>
....
</node1>
How can i write an xquery to find if there is a node2 that has name=a
请帮助,谢谢!
我尝试了以下方法,但似乎都不起作用。这些查询有什么问题?
select tbl.query('node1/node2[@name="a"]')
from tbl
select tbl.query('node1/node2[@name=''a'']')
from tbl
I have an xml structure like this:
<node1>
<node2 name="">
</node2>
<node2 name="">
</node2>
<node2 name="">
</node2>
....
</node1>
How can i write an xquery to find if there is a node2 that has name=a
Please help, thank you!
I tried the following but neither seemed to work. What is wrong with these queries?
select tbl.query('node1/node2[@name="a"]')
from tbl
select tbl.query('node1/node2[@name=''a'']')
from tbl
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需使用 XPath 选择
/node1/node2[@name = 'a']
(或//node2[@name = 'a']
)。如果select结果为空,则没有匹配的节点。
You'd simply select
/node1/node2[@name = 'a']
(or//node2[@name = 'a']
) with XPath.If the select result is empty, there is no matching node.