I am using XmlSerializer library to serialize object into xml. Here's what I get currently.
<?xml version="1.0" encoding="utf-8"?>
<Root xmlns:xsi=" xmlns:xsd=" <Expenses>
<Expense>
---
---
</Expense>
</Expenses>
</Root>
How can I add an attribute count='1' inside the <Expenses> element? so it looks like <Expenses count ='1'>
public static void SerializeDocument(string filename, List<Expense> expenses)
{
Root root = new Root();
root.expenses = expenses;
XmlSerializer serializer = new XmlSerializer(typeof(Root));
TextWriter writer = new StreamWriter(filename);
serializer.Serialize(writer, root);
writer.Close();
}
[XmlRootAttribute("Root", IsNullable = true)]
public class Root
{
[XmlArray(ElementName = "Expenses")]
public List<Expense> expenses;
}
<?xml version="1.0" encoding="utf-8"?>
<Root xmlns:xsi=" xmlns:xsd=" <Expenses>
<Expense>
---
---
</Expense>
</Expenses>
</Root>
How can I add an attribute count='1' inside the <Expenses> element? so it looks like <Expenses count ='1'>
public static void SerializeDocument(string filename, List<Expense> expenses)
{
Root root = new Root();
root.expenses = expenses;
XmlSerializer serializer = new XmlSerializer(typeof(Root));
TextWriter writer = new StreamWriter(filename);
serializer.Serialize(writer, root);
writer.Close();
}
[XmlRootAttribute("Root", IsNullable = true)]
public class Root
{
[XmlArray(ElementName = "Expenses")]
public List<Expense> expenses;
}