473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 1126
Cause u should replace node.ParentNode.WriteContentTo(XmlWtr); by
node.WriteTo(XmlWtr);
Thanks for me, lol

Dec 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: reddy | last post by:
I am trying to insert a node into an XMLFile. using XMLTextwriter. My Question is Is it possible to do without using XMLDocument. Because its loading all the the file into memory. I just want to...
3
by: Dave | last post by:
Hi, I'm trying to create an XML document with XMLTextWriter but I want to store it in memory (not write it to a file like so many examples do). I tried the following but with no luck. Should I not...
2
by: Josh Newman | last post by:
I'm using the XMLTextWriter to create an XML document. I do not want the encoding attribure in the XML file. Instead of: <?xml version="1.0" encoding="utf-8"?> I want: <?xml version="1.0"?>...
1
by: Riko Eksteen | last post by:
Hi I'm reading an xml file into an XmlDocument, adding some nodes, and writing it back out. I would like the nodes I add to assume the same level of indeting as the rest of the document. (I load...
0
by: Tom S. | last post by:
VS.Net ver 7.1.3088 ..Net Framework 1.1 ver 1.1.4322 SP1 When using an XmlTextWriter to write an xml document, how can I specify that the document needs to use a specific xsd file for...
2
by: Oenone | last post by:
I am using an XmlTextWriter to create an XML document, which we then send to a client. The document is failing to validate against the DTD we are providng when the load it into their...
5
by: Gilgamesh | last post by:
Hello, How do I use this class to create an XML document without saving it into a file? I need to store the XML documen into a string so it could be passed as a parameter to another class....
2
by: fmancina | last post by:
Hi, I am employing the XmlTextWriter class to generate an XML document. Everything works fine, until I have to write an attribute to an element which contains a value. Examples below: //...
3
by: GaryDean | last post by:
I'm using an XmlTextWriter and it's various methods such as WriteElementString, WriteStartElement, WriteEndElement, etc to create an xml document. When I instantiate the XmlTextWriter to a file......
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.