Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
使用xquery进行XML比较_Xml_Xslt_Xquery - Fatal编程技术网

使用xquery进行XML比较

使用xquery进行XML比较,xml,xslt,xquery,Xml,Xslt,Xquery,我对XSLT/Xquery非常陌生,希望比较两个xml文件(数据内容,可以忽略空格和注释),并打印第二个xml的更改节点。据我所知(谷歌搜索),我相信可以使用Xquery完成。我的xml如下所示 <ns:Batch xmlns:ns="http://www.sample.com/"> <ns:Product> <ns:productId>AB02921</ns:productId> <ns:type>Product<

我对XSLT/Xquery非常陌生,希望比较两个xml文件(数据内容,可以忽略空格和注释),并打印第二个xml的更改节点。据我所知(谷歌搜索),我相信可以使用Xquery完成。我的xml如下所示

<ns:Batch xmlns:ns="http://www.sample.com/">
<ns:Product>
    <ns:productId>AB02921</ns:productId>
    <ns:type>Product</ns:type>
    <ns:productDescription>
        <ns0:string xmlns:ns0="http://www.sample.com/core" country="US" language="en">EVE BOOTCUT JEAN</ns0:string>
    </ns:productDescription>
    <ns:productLongDescription>
        <ns0:string xmlns:ns0="http://www.sample.com/core" country="US" language="en">For perennial cool with an uber comfortable tw...</ns0:string>
    </ns:productLongDescription>
    <ns:posDetails>
        <ns:isTemplate>false</ns:isTemplate>
    </ns:posDetails>
    <ns:isTemplate>false</ns:isTemplate>
    <ns:lastUpdated>2011-09-07T16:52:50.573</ns:lastUpdated>
    <ns:exportDetails>
        <ns:isTemplate>false</ns:isTemplate>
    </ns:exportDetails>
    <ns:mmGroupId groupTypeId="mmGroup" groupHierarchyId="ABC" variantGroupTypeId="region" variantGroupId="All" variantGroupHierarchyId="All">JSBFO</ns:mmGroupId>
    <ns:inventoryDetails>
        <ns:isTemplate>false</ns:isTemplate>
    </ns:inventoryDetails>
    <ns:productDimensions>
        <ns:isTemplate>false</ns:isTemplate>
    </ns:productDimensions>
    <ns:warrantyDetails>
        <ns:isTemplate>false</ns:isTemplate>
    </ns:warrantyDetails>
    <ns:standardCostPrice>0.0</ns:standardCostPrice>
    <ns:standardMargin>0.0</ns:standardMargin>
    <ns:colourId colourRangeId="Default">6007</ns:colourId>
    <ns:sizeId sizeRangeId="Default">14</ns:sizeId>
    <ns:styleId>AB029</ns:styleId>
</ns:Product>

AB02921
产品
伊芙短靴牛仔裤
使用超级舒适的tw,持久保持凉爽。。。
假的
假的
2011-09-07T16:52:50.573
假的
JSBFO
假的
假的
假的
0
0
6007
14
AB029
我需要与的所有这些重复节点进行比较,以返回此节点中更改的节点。请大家帮我做同样的事情。 当做
Sri.

XML比较并非微不足道。我倾向于使用XMLUnit来解决这类问题

比较两个XML文档是一项具有挑战性的任务,部分原因是要求这样做的人通常对问题没有很好的定义,实际上也不知道他们要求的是什么

也就是说,试试这个标准XPath 2.0函数:


序列化为文本,在><之间没有空格,并进行文本比较。如果您想要可视化表示,请使用google diff.或使用deepequal

Hi Dimitre,我相信我对我的问题有很好的理解,我的要求是比较两个使用相同XML结构的XML文件(数据比较)。@user823737:您的注释放在了错误的答案下面,所以我刚才偶然看到:)你需要读一点关于这个主题的书,然后你就会意识到其中的微妙之处。无论如何,
deep-equal()
可能就是你想要的。如果您决定接受我的答案,那么答案将以
deep-equal()
:)结尾