我想知道xdocument1和xdocument2之间的区别。在xdocument1上:
<prices>
<price>
<productid>P001</productid>
<price>1000</price>
<effectivedate>2015-05-11T00:00:00+7</effectivedate>
</price>
</prices>在xdocument2上:
<prices>
<price>
<productid>P001</productid>
<price>870</price>
<effectivedate>2015-05-11T00:00:00+7</effectivedate>
</price>
</prices>如何才能得到它们之间的区别,如果有效产品和产品具有相同的价值,那么它就不应该返回价格记录,如下所示:
<prices/>如果效果不同,如下所示:
在xdocument1上:
<prices>
<price>
<productid>P001</productid>
<price>1000</price>
<effectivedate>2015-05-12T00:00:00+7</effectivedate>
</price>
</prices>在xdocument2上:
<prices>
<price>
<productid>P001</productid>
<price>870</price>
<effectivedate>2015-05-11T00:00:00+7</effectivedate>
</price>
</prices>然后价格标签应该从xdocument1得到,返回:
<prices>
<price>
<productid>P001</productid>
<price>1000</price>
<effectivedate>2015-05-12T00:00:00+7</effectivedate>
</price>
</prices>发布于 2015-05-09 04:36:15
这看起来像你想要的那样起作用。
var query =
new XDocument(
new XElement(
"prices",
from p1 in xdocument1.Root.Elements("price")
join p2 in xdocument2.Root.Elements("price")
on p1.Element("productid").Value equals p2.Element("productid").Value
where p1.Element("effectivedate").Value != p2.Element("effectivedate").Value
select p1));这似乎很简单,所以如果我错过了什么,请告诉我。
发布于 2015-05-08 19:05:22
我想建议以下步骤
我更像一个爪哇人。我可以在某个时候用Java提供一个代码片段。
https://stackoverflow.com/questions/30128098
复制相似问题