XQuery 检索值

XQuery retrieval of a value

我有以下 T-SQL 使用两个条件确定行是否存在:

Declare @x xml = '
    <row ParentID="45" ObjectID="0" Node="root.local.navigation[7]" itemKey="page" itemValue="Confirmation" itemType="string" />
    <row ParentID="45" ObjectID="0" Node="root.local.navigation[7]" itemKey="visited" itemValue="false" itemType="bool" />'

SELECT @x.exist('/row[@Node eq "root.local.navigation[7]"] and /row[@itemValue eq "Confirmation"]')

问题:鉴于上述SELECT,我如何SELECT第二行的itemValue? 即,由于有一行 Node="root.local.navigation[7]" 和 itemValue="Confirmation",return 节点相同且 itemKey="visited"?[=11 的行中的 itemType 值=]

这个怎么样:

declare @x xml = '
<row ParentID="45" ObjectID="0" Node="root.local.navigation[7]" itemKey="page" itemValue="Confirmation" itemType="string" />
<row ParentID="45" ObjectID="0" Node="root.local.navigation[7]" itemKey="visited" itemValue="false" itemType="bool" />'

select case when @x.exist('/row[@Node eq "root.local.navigation[7]"] and /row[@itemValue eq "Confirmation"]') = 1 
    then @x.value('/row[@Node eq "root.local.navigation[7]" and @itemKey eq "visited"][1]/@itemType', 'varchar(50)') 
end as item_type