我有以下标签
<NodeA desc="Household">
<NodeA desc="Cheap">
<NodeA desc="Cheap Item 1" category="Cooking" />
<NodeA desc="Cheap Item 2" category="Gardening" />
</NodeA>
</NodeA>
<NodeA> ...and so on
在这里有帮助的人的帮助下,我必须使用以下方法检索类别列表:
.Where(attr => attr.Name == "category")
.Select(attr => attr.Value);
现在我要检索'desc'和'category'。我怎么能这样做?
答案 0 :(得分:2)
像这样......(未经测试)
from c in context
where c.Attribute("category") == "category name"
select new
{
Description = c.Attribute("desc"),
Category = c.Attribute("category")
}
完全未经测试,但这些方面应该有效。