First of all, the problem has nothing to do with Forms, or any other kind of UI. Now,
appending any text to some valid XML is impossible, in the following sense: if you do that, the text is transformed to the text which cannot be, according the XML standard, a
well-formed XML. This is because XML can have only one root element.
To obtain some well-formed XML, you can only
add/insert some XML as a child(red) to existing XML element. To manipulate XML, .NET FCL offers different approaches. Here is my short overview of them:
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the classes
System.Xml.XmlTextWriter
and System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that of XmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
Good luck,
—SA