How to append records in exist XMl file?

  • Thread starter Thread starter Matrix
  • Start date Start date
M

Matrix

I want to append records in a XML file,I use XMLTextWriter,but i found it
only create a XML file,not append records in exist XML file.why?
-------------------------------------------------
XmlTextWriter myXmlTextWrite = new XmlTextWriter(@"C:\myconfig.xml");
myXmlTextWrite.WriteStartDocument();
myXmlTextWrite.WriteStartElement("Record");
myXmlTextWrite.WriteStartElement("Topic");
myXmlTextWrite.WriteString(XMLTopic);
myXmlTextWrite.WriteEndElement();
myXmlTextWrite.WriteEndElement(); //end Record
myXmlTextWrite.WriteEndDocument();
myXmlTextWrite.Flush();
myXmlTextWrite.Close();
=================================================
i should use XMLDocument?
 
Hi,

The XmlTextWriter was not designed to append data to existing documents -
you should, as you suggested yourself, use XmlDocument if you want to append
xml data to an existing document.
 
Back
Top