Groups | Blog | Home
all groups > dotnet xml > october 2004 >

dotnet xml : XML Array serialization problem


Raj Suryadevara via .NET 247
10/31/2004 3:52:44 AM
Hi
I am using XML serializationn in C#=2E I have code like this=2E

public class Doc
{
[XmlArrayItem (ElementName=3D"TNArray",
Type=3Dtypeof(ReTN[]))]
public object[] Obj;
}


[XmlRoot("TNA")]
public class ReTN
{something=2E=2E=2E}

Here I am trying to set XML node as "TNA" instead of class name=
"ReTN"=2E [XmlRoot("TNA")] works when I serialize single object,=
that means when I say [XmlElement(Type=3Dtypeof(ReTN))]=2E In single=
object case I am getting node name as "TNA"=2E If I serialize=
array of objects as I was doing above it gives class=
name("ReTN") as node name=2E Any thoughts=2E

Any help is greatly appreciated=2E

Thanks
Raj
--------------------------------
From: Raj Suryadevara

-----------------------
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)

Christoph Schittko [MVP]
11/9/2004 9:56:20 AM

You need to pass the XmlRoot attribute to the constructor of the
XmlSerializer:

XmlSerialzer ser = new XmlSerializer( typeof( ReTN[] ), new XmlRoot(
"TNA" ) );

HTH,
Christoph Schittko
MS MVP XML
http://weblogs.asp.net/cschittko

[quoted text, click to view]
AddThis Social Bookmark Button