Serialize and append

  • Thread starter Thread starter Hell
  • Start date Start date
H

Hell

I have 2 objects of same type with data in them. I serialize 1 of them to an
xml file using XmlSerializer and XmlWriter. now can i serialize the other
one to the same file so it appends to the file after the data from the first
one?
 
The last time I worked with XmlSerializer it seemed to output an entire,
properly formatted XML document. Therefore if you plan on serializing into
the same file, you'll get an invalid XML file as there will be 2 <?xml?>
tags and 2 root elements.

I haven't tried this, but if you customize the output, then you should be
able to do it. Customize could be:
- write your own XmlWriter subclasses class that will strip out the
unnecessary tags
- output to string, strip out the invalid tags in the string, then manually
write the string into the file
....

Hope this helps.

Eric
 
Back
Top