c# xmlarray and xmlarrayitem
I'm trying to use XMLSerializer and have the following code:
[XmlArray("ToggleExclusion")]
[XmlArrayItem("Result")]
public string[] toCopy { get; set; }
And I serialise as such:
XmlSerializer x = new XmlSerializer(typeof(string[]));
StringWriter w = new StringWriter();
x.Serialize(w, toCopy);
开发者_如何学GoHowever, when the xml is printed, the elements are: typeofstring, and string.
What am I missing here to ensure the elements are as I want above.
You need to use XmlRoot for the root item. It ignores the XmlArray or XmlElement tag for the root.
You may also specify the root name in the XmlSerializer constructor.
精彩评论