XMLSerializer Deserialization - array element order



We are using XMLSerializer.Deserialize(XMLReader) on .Net 4.5 to deserialize XML into an Object Graph generated by xsd.exe.


I would like to know what the expected deserialization behavior is for an array which is annotated with the XMLElementAttribute - specifically with regard to ordering. For example:


For the following property:



[System.Xml.Serialization.XmlElementAttribute("GivenName")]
public string[] GivenName {
// get() and set() methods
}


And the following XML:



<root>
<GivenName>One</GivenName>
<GivenName>Two</GivenName>
<GivenName>Three</GivenName>
</root>


Will this always deserialize as ['One', 'Two', 'Three']


So that the array order always matches the XML order


Also is there any documentation I can reference that clearly states this.


Thanks


Rob


No comments:

Post a Comment