473,835 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to append records in exist XMl file?

Greetings

I want to append records in a XML file,I use XMLTextWriter,b ut i found it
only create a XML file,not append records in exist XML file.why?
-------------------------------------------------
XmlTextWriter myXmlTextWrite = new XmlTextWriter(@ "C:\myconfig.xm l");
myXmlTextWrite. WriteStartDocum ent();
myXmlTextWrite. WriteStartEleme nt("Record");
myXmlTextWrite. WriteStartEleme nt("Topic");
myXmlTextWrite. WriteString(XML Topic);
myXmlTextWrite. WriteEndElement ();
myXmlTextWrite. WriteEndElement (); //end Record
myXmlTextWrite. WriteEndDocumen t();
myXmlTextWrite. Flush();
myXmlTextWrite. Close();
=============== =============== =============== ====
i should use XMLDocument?
------------------------------
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(@"C :\myconfig.xml" );
xmldoc.Document Element.AppendC hild() //????????

Nov 12 '05 #1
2 12913
that's the whole idea (XmlTextWriter has to validate content as XML ...), so
using XmlDoxument makes sense ...
"Matrix" <co*****@163.co m> wrote in message
news:eE******** ********@TK2MSF TNGP10.phx.gbl. ..
Greetings

I want to append records in a XML file,I use XMLTextWriter,b ut i found it
only create a XML file,not append records in exist XML file.why?
-------------------------------------------------
XmlTextWriter myXmlTextWrite = new XmlTextWriter(@ "C:\myconfig.xm l");
myXmlTextWrite. WriteStartDocum ent();
myXmlTextWrite. WriteStartEleme nt("Record");
myXmlTextWrite. WriteStartEleme nt("Topic");
myXmlTextWrite. WriteString(XML Topic);
myXmlTextWrite. WriteEndElement ();
myXmlTextWrite. WriteEndElement (); //end Record
myXmlTextWrite. WriteEndDocumen t();
myXmlTextWrite. Flush();
myXmlTextWrite. Close();
=============== =============== =============== ====
i should use XMLDocument?
------------------------------
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(@"C :\myconfig.xml" );
xmldoc.Document Element.AppendC hild() //????????

Nov 12 '05 #2
Matrix wrote:
I want to append records in a XML file,I use XMLTextWriter,b ut i found it
only create a XML file,not append records in exist XML file.why?


XML document is tree-like structure, so to append records one has to
rearrange structure, what hardly possible in file on disk.
The only case when XmlWriter can append data to XML file is when it's
not XML document, but XML fragment (XML document with more than single
root element). That's common pattern for writing XML-based log files. As
there is no single root element rule, you can merely append records to
the end of file:

<log time="..." event="..."/>
<log time="..." event="..."/>
<log time="..." event="..."/>

Above is XML fragment, which is easily appendable and can be incpropated
into another document via external entity or just read using
XmlTextReader, which happily supports reading of XML fragments.
See sample at http://www.tkachenko.com/blog/archives/000053.html

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #3

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

Similar topics

3
23962
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
5790
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 database and then i create a basic append query that appends the new records to the table(tblonlinereg). this works great if the field is greater than the last record appended ( where: tempID > 198 ) but how would i update/append the modifications...
3
2923
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 like to append table 1 with all of the new records, and do it unattended in a macro. Is there a way to specify in the append query to only append the
13
4234
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 solution here - until now. This one is driving me crazy. I am making my first attempt at creating a runtime application. I am using Access 2003 Developer Extensions. Initially I developed the database without planning on creating a runtime app...
1
3039
by: Matrix | last post by:
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);...
5
2256
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 orders2. But I want to find the highest ordered in the table orders2 instead. In short, I want to append the order from the table orders2 into the table orders1 and this order to get the next highest ordered.Somehow I canot manage it.Can you help...
0
1100
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
7392
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 imported text file. I can update the data through an update query or append the entire import table through an append query. Is there a way to combine the two so that I can update existing records and append only new records (without duplicating...
3
8092
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 incur numerous service problems “Events”. Each morning we have a global conference call where events which occurred within the previous 24 hours are discussed. Prior to the call, an analyst has to review these events and provide a report, ‘The Morning...
0
10524
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10562
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10236
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6968
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3092
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.