且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 XQuery/XPath 获取元素父节点的属性值

更新时间:2023-02-08 22:49:02

您编写的查询正在选择属性 f.但是,从 XQuery 返回属性节点是不合法的.错误是指输出文档,这里只包含一个属性(虽然这个错误信息有误导性,因为从技术上讲,这里没有输出文档,只返回了一个属性节点).

The query you have written is selecting the attribute f. However it is not legal to return an attribute node from an XQuery. The error is refering to the output document which here contains just an attribute (although this error message is misleading, as technically there is no output document here, there is just an attribute node that is returned).

您可能想返回属性的值而不是属性本身

You probably wanted to return the value of the attribute rather than the attribute itself

return data($foonode)