【发布时间】:2012-03-14 02:08:35
【问题描述】:
我有以下xml
<root>
<document>
<account>12</account>
<type name-"a">stuff</type>
<type name-"b">stuff</type>
</document>
<document>
<account>42</account>
<type name-"a">stuff</type>
<type name-"b">good stuff</type>
<type name-"c">good stuff</type>
</document>
</root>
我想使用 LINQ to XML 为 xml 中的每个文档返回一个 Document 类对象 将类型属性名称为“b”的账户值和类型值放入类中
class Document {
public string Account { get; set; }
public string BType { get; set; }
}
我不确定我如何迭代类型,或者你是否可以比使用谓词更整洁
谢谢 标记
【问题讨论】: