Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml Xpath-选择每个图书列表包含的存储_Xml_Xpath - Fatal编程技术网

Xml Xpath-选择每个图书列表包含的存储

Xml Xpath-选择每个图书列表包含的存储,xml,xpath,Xml,Xpath,我对特定的XPath查询有问题。这与SO问题非常相似: 在我的例子中,XML是这样的 <x> <stores> <store> <book>b1</book> </store> <store> <book>b2</book> </store>

我对特定的XPath查询有问题。这与SO问题非常相似:

在我的例子中,XML是这样的

<x>
    <stores>
        <store>
            <book>b1</book>
        </store>
        <store>
            <book>b2</book>
        </store>
        <store>
                <book>b4</book>
        </store>
    </stores>
    <Lists>
        <List>
            <wanted>
                <book>b1</book>
                <book>b2</book>
            </wanted>
        </List>
        <List>
            <wanted>
                <book>b1</book>
                <book>b4</book>
            </wanted>
        </List> 
        <List>
            <wanted>
                <book>b1</book>
            </wanted>
        </List>
    </Lists>
</x>

但它会选择至少发生一次的每个门店。

您希望所有门店都没有不包含该门店书籍的
列表。我认为这不能在纯XPath1.0中实现,因为它需要在内部谓词中访问与外部表达式匹配的元素

/x/stores/store[not(/x/Lists/List[wanted/book != $outer/book])]
            ^
       This store is $outer
在XPath2.0中,可以使用
每一个

/x/stores/store[every $list in /x/Lists/List satisfies $list/wanted/book = book]

您希望所有商店都没有不包含该商店书籍的
列表
。我认为这不能在纯XPath1.0中实现,因为它需要在内部谓词中访问与外部表达式匹配的元素

/x/stores/store[not(/x/Lists/List[wanted/book != $outer/book])]
            ^
       This store is $outer
在XPath2.0中,可以使用
每一个

/x/stores/store[every $list in /x/Lists/List satisfies $list/wanted/book = book]

@用户3080997您介意接受伊恩的回答吗。如果有帮助的话,你可以为此获得几分@当然,是的。这是我在这里的第一个问题,我不习惯所有的功能。@user3080997你介意接受伊恩的回答吗。如果有帮助的话,你可以为此获得几分@当然,是的。这是我在这里的第一个问题,我并不习惯于所有的功能。