XmlSerializer question

  • Thread starter Thread starter Dirk Reske
  • Start date Start date
D

Dirk Reske

Hello,

how can I create following file with the Serializer?

<xml ...>
<Items>
<Item Key="1">Item 1</Item>
<Item Key="2">Item 2</Item>
...
</Items>
</xml>
 
You could do it as follows:

[XmlRoot("Item")]
class Item
{
[XmlAttribute("Key")]
public string Key;

[XmlText]
public string Value;
}
 
Back
Top