473,386 Members | 1,610 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,386 software developers and data experts.

How to append records in exist XMl file?

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?
------------------------------
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(@"C:\myconfig.xml");
xmldoc.DocumentElement.AppendChild() //????????
Nov 15 '05 #1
1 3016
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.

--
Regards,
Thomas Johansen (aka. Aylar)
Matrix <co*****@163.com> wrote:
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?
------------------------------
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(@"C:\myconfig.xml");
xmldoc.DocumentElement.AppendChild() //????????

Nov 15 '05 #2

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

Similar topics

3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
2
by: Matrix | last post by:
Greetings 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?...
2
by: JMCN | last post by:
hi i have a general question regarding append queries in access 97. each week i need to update my table(tblonlinereg) with new or modified records. firstly, i import the text file into my...
3
by: Larry Rekow | last post by:
As part of a macro, I'm trying to automate appending a table with new records. let's say the table 2 has some new records in it, but also has a lot of identical records to table 1. I would...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
5
by: solar | last post by:
I have copied a function that appends from table orders2 into table orders1 the row that has the value SubOrder = True in the table orders2. This function finds the highest ordered in the table...
0
by: RJN | last post by:
Hi I'm using XMlSerailizer to write certain content to file. If the file exists, I'm supposed to append the xml to the file. eg., <EmployeeList> <Employee></Employee> </EmployeeList>
4
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the...
5
by: jkn | last post by:
Hi all Python 2.4.2 (#1, Apr 26 2006, 23:35:31) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.