[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Serialize/Deserialize

Roy

4/8/2008 12:57:00 PM

I have a C# class generated by xsd.exe from the xsd file. I also have an xml
file defined by xsd and the root looks like:

<MyNickname:MyObject xmlns:MyNickname="..." xmlns:xsi="..."
xsi:schemaLocation="...">
....

However, these attributes in the root are lost when I deserialize the xml
into the C# file so that if I serialize it back to the xml file again, it
will be different than the original file.
Is that a way to serialize the attributes to the C# class to reserve the
information? I am using both the XmlSerilizer and DataContractSerializer.
1 Answer

Peter Ritchie [C# MVP]

4/10/2008 5:05:00 PM

0

Maybe I'm not following you, but XSD.exe creates an XML Schema file--that
describes a type. Serialization serializes to XML (in this case). One
snippet of XML describes the type, a the other describes and instance of the
type. They won't have the same attributes.
--
Browse http://connect.microsoft.com/VisualStudio... and vote.
http://www.peterRitchie...
Microsoft MVP, Visual Developer - Visual C#


"Roy" wrote:

> I have a C# class generated by xsd.exe from the xsd file. I also have an xml
> file defined by xsd and the root looks like:
>
> <MyNickname:MyObject xmlns:MyNickname="..." xmlns:xsi="..."
> xsi:schemaLocation="...">
> ....
>
> However, these attributes in the root are lost when I deserialize the xml
> into the C# file so that if I serialize it back to the xml file again, it
> will be different than the original file.
> Is that a way to serialize the attributes to the C# class to reserve the
> information? I am using both the XmlSerilizer and DataContractSerializer.