Hi.
I need to build an xml like this
<Dimension>
<element>MM9</element>
<element>JKS</element>
<element>FFES</element>
</Dimension>
The "element" attribute is repeated several times with the same name.
What would be the correct way to do it?
Thanks a lot.
Regards.
What I have tried:
I have tried creating the Dimension class and element attributes
<pre lang="C#">
public class Dimension
{
[XmlElement("element")]
public string element1 { get; set; }
[XmlElement("element")]
public string element2 { get; set; }
[XmlElement("element")]
public string element3 { get; set;
}
When I serialize the class I get an error for having attributes with the same name.
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(Dimension.GetType());
x.Serialize(Console.Out, Dimension);
i tried with a list
public class element
{
[XmlElement("element")]
public string element1 { get; set; }
}
public List<element> Dimension = new List<element>();
But the result is not what I need
<Dimension>
<element>
<element>MM9</element>
</element>
</Dimension>