For example, the xmlarrayitem attribute is used to indicate the element types in the array:
Public Class A
{
[ Xmlarrayitem (Type = Typeof ( Int )), Xmlarrayitem (Type = Typeof ( Guid )), Xmlarrayitem (Type = Typeof ( String )]
Public Object[] Arr= New Object[] {12,"Hehe",Guid.Newguid ()};
}
The serialized XML is:
<A Xmlns: xsi="Http://www.w3.org/2001/XMLSchema-instance"
Xmlns: XSD="Http://www.w3.org/2001/XMLSchema">
<Arr>
<Int>12</Int>
<String>Hehe</String>
<Guid>291b7cba-fc32-4019-bb22-d5d61643b6a7</Guid>
</Arr>
</A>
The arr field name is written as an XML element.
However, if you change xmlarrayitem to xmlelement:
Public Class A
{
[ Xmlelement (Type = Typeof ( Int )), Xmlelement (Type = Typeof ( Guid )), Xmlelement (Type = Typeof ( String )]
Public Object[] Arr= New Object[] {12,"Hehe",Guid.Newguid ()};
}
The serialized XML is as follows:
<A Xmlns: xsi="Http://www.w3.org/2001/XMLSchema-instance"
Xmlns: XSD="Http://www.w3.org/2001/XMLSchema">
<Int>12</Int>
<String>Hehe</String>
<Guid>5e7da5a0-d513-47b7-ae8f-80b404a9b0d4</Guid>
</A>
There is no arr field name!
Note that you can use xmlarrayitem or elementname of xmlelement to control the names of XML elements of the corresponding type.