471,315 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,315 software developers and data experts.

XmlTextWriter Probelm to create a new document

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

Dec 14 '05 #1
1 1073
Cause u should replace node.ParentNode.WriteContentTo(XmlWtr); by
node.WriteTo(XmlWtr);
Thanks for me, lol

Dec 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Josh Newman | last post: by
1 post views Thread by Riko Eksteen | last post: by
reply views Thread by Tom S. | last post: by
5 posts views Thread by Gilgamesh | last post: by
2 posts views Thread by fmancina | last post: by
3 posts views Thread by GaryDean | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.