Is it possible to have a single stream and have more than one XmlWriter write to that stream and end up with well-formed XML?
I have an object hierarchy in which each object is solely and fully responsible for serializing itself. My latest attempt has been to create a stream at the highest level, then pass that stream reference down and allow each object to create its own XmlWriter to serialize itself to the stream. However, this ends up creating nodes within incomplete parent nodes (the start element is not fully formed in the parent before child content is written, even with a flush).
There are multiple appdomains, so passing the XmlWriter reference will not work. I was having each object return a string and writing that raw XML string into the stream, but some of the strings get to be very, very long (collections). That's why I decided on a stream -- so that each object could write out small pieces at a time and a stream instance is both serializable and MBR.
I decided against using XmlSerializer for reasons I didn't seem to document. But I'm going to trust my earlier judgment on that.
Thanks for anything that can lead to a more thorough understanding of what I'm working with.