Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLReader & XMLWriter

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
Hello.
I'm primarily a Java programmer but have just started using C#.

I'm trying to write all attributes in a class to an XML file which I can do by explicitly naming the nodes and attributes to be written to the XML file. However in Java you could just pass the object to write to XML to the XML writing method (like Serialization), does C# support anything like this?

Any and all suggestions would be most welcome.
Thankyou

we are all of us living in the gutter.
But some of us are looking at the stars.
 
C# has two main serializers -- binary and XML. They both have limitations.

Binary works, but embeds the assembly version, strong name, etc. in the stream. So if you serialize your object to disk (database, file, etc), and then upgrade the assembly, you won't be able to de-serialize your data back into an object. It's best used for a communications channel, not long-term storage.

XML doesn't embed the strong name, version etc., but it won't recurse through encapsulated objects. IOW, it only goes thru the value objects in the class itself, and won't drill down to the reference objects.

I've ended up writing my own serialization code to get around these problems.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Dont know if this helps or not but you could implement the Iserializable interface in your c# classes and define how serilization and deserailization is done for that class. This could help with backward compatability.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top