【发布时间】:2010-10-16 14:49:29
【问题描述】:
我想我正在突破 LINQ to XML 的能力范围,但我想选择一组元素,这些元素包含的值与另一个元素节点中包含的值相匹配。
在下面的 XML 中,我只想选择包含特定产品 ID 的 AvailableOptions 元素中的值的“Option”元素。
类似于下面的伪代码:
选择选项名称所在的所有选项(Select AvailableOptions Where ProductID = "xxx")
<Agents>
<Agent ID="1">
<Login>111</Login>
<Password>pass</Password>
<Products>
<Product ID="xxx">
<AvaiableOptions>aaa,bbb</AvaiableOptions>
</Product>
</Products>
<Products>
<Product ID="yyy">
<AvaiableOptions>bbb,ccc</AvaiableOptions>
</Product>
</Products>
<Products>
<Product ID="zzz">
<AvaiableOptions>aaa,ccc</AvaiableOptions>
</Product>
</Products>
<Options>
<Option>
<Name>aaa</Name>
<Value>10</Value>
</Option>
<Option>
<Name>bbb</Name>
<Value>20</Value>
</Option>
<Option>
<Name>ccc</Name>
<Value>30</Value>
</Option>
</Options>
</Agent>
【问题讨论】:
标签: linq linq-to-xml