Serialize/Deserialize

R

Roy

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.
 
P

Peter Ritchie [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top