小编Fra*_*ank的帖子

使用嵌套的XPath谓词......精炼

所有好的答案!但问题值得改进......

我有以下示例XML ...

<objects>
    <object objectId="1123" ... />
    <properties refObjectId="1123" ... />
    <properties refObjectId="1123" refPropertyId="2311" ... />
    <properties refObjectId="1123" refPropertyId="4611" ... />
    <object objectId="2123" ... />
    <properties refObjectId="2123" refPropertyId="4311" ... />
    <properties refObjectId="2123" refPropertyId="8611" ... />
    ....
</objects>
Run Code Online (Sandbox Code Playgroud)

...以及以下XPath查询...

//object[//properties[@refObjectId=@objectId and not(@refPropertyId)]]
Run Code Online (Sandbox Code Playgroud)

我想这个查询将返回所有object节点那里是一个properties具有节点refObjectId,等于属性objectId的属性object节点,并没有"refPropertyId"属性...即对象1123只,不反对2123 ...但事实并非如此.似乎@objectId嵌套谓词中没有引用节点的objectId属性object.

有任何想法吗?我知道XML结构没有像你期望的那样嵌套,但是有这种结构的原因.

xpath

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

xpath ×1