I have the following code:
public class Foo {}
static class Program {
[XmlElement("foo")] // Ignored :(
static public List<Foo> MyFoos { get; private set; }
public static void Main() {
MyFoos.Add(new Foo());
MyFoos.Add(new Foo());
XmlSerializer configSerializer =
new XmlSerializer(typeof(List<Foo>), new XmlRootAttribute("foos"));
using (TextWriter w = new StreamWriter("test.xml"))
{
s.Serialize(w, MyFoos);
}
}
}
Which produces the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<foos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Foo />
<Foo />
</foos>
What I would really like to have is the Foo
elements labeled as foo
, instead... I realise this is mostly cosmetic, but it fits with what is generally considered normal in XML.