XmlTextWriter Probelm to create a new document

  • Thread starter Thread starter Point.Cube
  • Start date Start date
P

Point.Cube

Here is my code, but the problem is I want to recreate a new file but
at the and I find that the program add the new element the old ones!!

****************************************
System.IO.File.Delete( mXmlFile);
System.Xml.XmlTextWriter XmlWtr = new System.Xml.XmlTextWriter(
mXmlFile, null);
XmlWtr.Formatting = System.Xml.Formatting.Indented;

XmlWtr.WriteStartDocument();
XmlWtr.WriteStartElement( "Elemt1");

foreach(System.Xml.XmlNode node in mClients.Values)
{
node.ParentNode.WriteContentTo(XmlWtr);
}

XmlWtr.WriteEndElement();
XmlWtr.WriteEndDocument();
XmlWtr.Flush();
XmlWtr.Close();
****************************
Thanks for help
 
Cause u should replace node.ParentNode.WriteContentTo(XmlWtr); by
node.WriteTo(XmlWtr);
Thanks for me, lol
 
Back
Top