我试图找出从两个不同元素派生的多重 where 子句。基本上,我希望能够根据 DataType & Service 元素的名称属性进行过滤。感谢任何反馈。谢谢杰
var services = from dt in doc.Descendants("DataType")
where (string)dt.Attribute("name") == "WELL_INDUSTRY" && (string)dt.Elements("Service").Attributes == "Well_Industry"
from service in dt.Elements("Services").Elements("Service").Elements("Layers").Elements("Layer")
select new
{
Name = (string)service.Attribute("name"),
};
XML:
<DataTypes>
<DataType name="WELL_INDUSTRY">
<Spatial>
<Services>
<Service name="Well_Industry" group="Well" status="Primary" >
<Layers>
<layer name="Bottom Hole Wells" ></layer>
<layer name="Bottom Hole Wells2" ></layer>
</Layers>