Sample1.xml
<data><row><id>949459</id><product_id>4119945117</product_id></row>
<row><id>781351</id><product_id>1009460692</product_id></row>
<row><id>780163</id><product_id>1009755673</product_id></row>
<row><id>1017226</id><product_id>1013393868</product_id></row>
<row><id>1017956</id><product_id>1013393871</product_id></row>
<row><id>1017310</id><product_id>1013393874</product_id></row>
<row><id>771708</id><product_id>4388803569</product_id></row>
<row><id>3270790</id><product_id>1013679270</product_id></row>
<row><id>775869</id><product_id>1014142699</product_id></row>
<row><id>1017599</id><product_id>1021870484</product_id></row>
<row><id>1018789</id><product_id>1021870489</product_id></row>
<row><id>1017091</id><product_id>1021870491</product_id></row>
<row><id>1017333</id><product_id>1021870492</product_id></row>
<row><id>1017630</id><product_id>1021870493</product_id></row>
<row><id>1017774</id><product_id>1021870495</product_id></row>
<row><id>1018192</id><product_id>1021870496</product_id></row>
<row><id>1018725</id><product_id>4408034849</product_id></row>
<row><id>1017990</id><product_id>1021870498</product_id></row>
<row><id>1018027</id><product_id>1021870499</product_id></row>
<row><id>1017166</id><product_id>1021870500</product_id></row>
<row><id>769120</id><product_id>1032140806</product_id></row>
<row><id>950336</id><product_id>1035310069</product_id></row>
</data>
示例2.xml
<productSet>
<row><product>4388803569</product></row>
<row><product>4408034289</product></row>
<row><product>4408034589</product></row>
<row><product>4408034849</product></row>
<row><product>4094557957</product></row>
<row><product>4119945117</product></row>
</productSet>
这是我的 Xquery,通过与示例 2 文件中的 product_id 元素进行比较,返回来自 sample1 XML 文件的所有产品元素值。在这里,我试图检索所有不可用的产品。
<outProduct_10310>
{ for $b in doc("sample1.xml")/data/row,
$a in doc("sample2.xml")/productSet/row[product != $b/product_id]
return
<op_id> { $b/product_id/text() } </op_id>
} </outProduct_10310>
当我将这两个 XML 与等号进行比较但我想检索不匹配的数据时,此代码将返回正确的匹配数据,但如果我运行上面的代码,它会给出以下输出:
<outProduct_10310>
<op_id>4119945117</op_id>
<op_id>4119945117</op_id>
<op_id>4119945117</op_id>
<op_id>4119945117</op_id>
<op_id>4119945117</op_id>
<op_id>1009460692</op_id>
<op_id>1009460692</op_id>
<op_id>1009460692</op_id>
<op_id>1009460692</op_id>
<op_id>1009460692</op_id>
<op_id>1009460692</op_id>
<op_id>1009755673</op_id>
<op_id>1009755673</op_id>
<op_id>1009755673</op_id>
<op_id>1009755673</op_id>
<op_id>1009755673</op_id>
<op_id>1009755673</op_id>
<op_id>1013393868</op_id>
<op_id>1013393868</op_id>
<op_id>1013393868</op_id>
<op_id>1013393868</op_id>
<op_id>1013393868</op_id>
<op_id>1013393868</op_id>
<op_id>1013393871</op_id>
<op_id>1013393871</op_id>
<op_id>1013393871</op_id>
<op_id>1013393871</op_id>
<op_id>1013393871</op_id>
<op_id>1013393871</op_id>
<op_id>1013393874</op_id>
<op_id>1013393874</op_id>
<op_id>1013393874</op_id>
<op_id>1013393874</op_id>
<op_id>1013393874</op_id>
<op_id>1013393874</op_id>
<op_id>4388803569</op_id>
<op_id>4388803569</op_id>
<op_id>4388803569</op_id>
<op_id>4388803569</op_id>
<op_id>4388803569</op_id>
<op_id>1013679270</op_id>
<op_id>1013679270</op_id>
<op_id>1013679270</op_id>
<op_id>1013679270</op_id>
<op_id>1013679270</op_id>
<op_id>1013679270</op_id>
<op_id>1014142699</op_id>
<op_id>1014142699</op_id>
<op_id>1014142699</op_id>
<op_id>1014142699</op_id>
<op_id>1014142699</op_id>
<op_id>1014142699</op_id>
<op_id>1021870484</op_id>
<op_id>1021870484</op_id>
<op_id>1021870484</op_id>
<op_id>1021870484</op_id>
<op_id>1021870484</op_id>
<op_id>1021870484</op_id>
<op_id>1021870489</op_id>
<op_id>1021870489</op_id>
<op_id>1021870489</op_id>
<op_id>1021870489</op_id>
<op_id>1021870489</op_id>
<op_id>1021870489</op_id>
<op_id>1021870491</op_id>
<op_id>1021870491</op_id>
<op_id>1021870491</op_id>
<op_id>1021870491</op_id>
<op_id>1021870491</op_id>
<op_id>1021870491</op_id>
<op_id>1021870492</op_id>
<op_id>1021870492</op_id>
<op_id>1021870492</op_id>
<op_id>1021870492</op_id>
<op_id>1021870492</op_id>
<op_id>1021870492</op_id>
<op_id>1021870493</op_id>
<op_id>1021870493</op_id>
<op_id>1021870493</op_id>
<op_id>1021870493</op_id>
<op_id>1021870493</op_id>
<op_id>1021870493</op_id>
<op_id>1021870495</op_id>
<op_id>1021870495</op_id>
<op_id>1021870495</op_id>
<op_id>1021870495</op_id>
<op_id>1021870495</op_id>
<op_id>1021870495</op_id>
<op_id>1021870496</op_id>
<op_id>1021870496</op_id>
<op_id>1021870496</op_id>
<op_id>1021870496</op_id>
<op_id>1021870496</op_id>
<op_id>1021870496</op_id>
<op_id>4408034849</op_id>
<op_id>4408034849</op_id>
<op_id>4408034849</op_id>
<op_id>4408034849</op_id>
<op_id>4408034849</op_id>
<op_id>1021870498</op_id>
<op_id>1021870498</op_id>
<op_id>1021870498</op_id>
<op_id>1021870498</op_id>
<op_id>1021870498</op_id>
<op_id>1021870498</op_id>
<op_id>1021870499</op_id>
<op_id>1021870499</op_id>
<op_id>1021870499</op_id>
<op_id>1021870499</op_id>
<op_id>1021870499</op_id>
<op_id>1021870499</op_id>
<op_id>1021870500</op_id>
<op_id>1021870500</op_id>
<op_id>1021870500</op_id>
<op_id>1021870500</op_id>
<op_id>1021870500</op_id>
<op_id>1021870500</op_id>
<op_id>1032140806</op_id>
<op_id>1032140806</op_id>
<op_id>1032140806</op_id>
<op_id>1032140806</op_id>
<op_id>1032140806</op_id>
<op_id>1032140806</op_id>
<op_id>1035310069</op_id>
<op_id>1035310069</op_id>
<op_id>1035310069</op_id>
<op_id>1035310069</op_id>
<op_id>1035310069</op_id>
<op_id>1035310069</op_id>
</outProduct_10310>
我对 xquery 完全陌生。谁能帮助我如何获取不匹配的数据?