XML 配列要素の属性を読み取るにはどうすればよいでしょうか? 以下のコードは、動作していない XML 配列要素の属性を読み取るために使用します。利用可能な場合、または不足していた場合に読む代替ソリューションを教えてください。たくさんのサンプルを見ましたが、欠けているものを特定できませんでした。
読み込むソースxmlは
<RootElement>
<devices AttNAme="attValue">
<device>
<sometag/>
<device>
<device>
<sometag/>
<device>
</devices>
<RootElement>
私が使用するコードは
[XmlRoot("RootElement")]
public class RootElement
{
[XmlArrayItem("DeviceType", typeof(DeviceTypeSection))]
[XmlArray("devices")]
public DeviceTypesSection DeviceTypesInfo { get; set; }
}
[XmlType("DeviceTypes")]
public class DeviceTypesSection : List<DeviceTypeSection>
{
[XmlAttribute("AttNAme")]
public string AttNAme{ get; set; }
}
..and so on
ありがとう、