开发者

Help with xquery

开发者 https://www.devze.com 2023-01-23 23:54 出处:网络
I have an xml structure like this: <node1> <node2 name=\"\"> </node2> <node2 name=\"\">

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/no开发者_JAVA百科de2[@name=''a'']')
from tbl


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.

0

精彩评论

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