开发者

Help with xquery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜