问题描述
<?xmlversion="1.0"encoding="utf-8"?><Barcodes><BarcodeID="001"HybStatus=""FluidicsStatus=""ScanStatus=""ScanAgccPath=""><sample1ScanPegStatus="aa">111</sample1><sample2ScanPegStatus="bb">222</sample2><sample3ScanPegStatus="cc">333</sample3><sample4ScanPegStatus="dd">444</sample4></Barcode></Barcodes>条件:ID=001,sample=333,查询出来元素ScanPegStatus的“CC”值!
解决方案
解决方案二:
XElementxmlTree=newXElement("Barcodes",newXElement("sample1",newXAttribute("ScanPegStatus","aa")),newXElement("sample2",newXAttribute("ScanPegStatus","bb")),newXElement("sample3",newXAttribute("ScanPegStatus","cc")));XElementxmlTree2=newXElement("Barcodes",fromelinxmlTree1.Elements()where(el.Attributes["Id"]=='001'&&(int)el.Attributes["sample"]=="333")selectel);我没测试你自己慢慢尝试下吧
解决方案三:
谢谢楼上的回答,可是您的where条件里面是错误的