How to append records in exist XMl file?

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?
-------------------------------------------------
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()   //????????



0
Matrix
2/23/2004 2:04:50 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
493 Views

Similar Articles

[PageSpeed] 16

that's the whole idea (XmlTextWriter has to validate content as XML ...), so
using XmlDoxument makes sense ...
"Matrix" <cowbird@163.com> wrote in message
news:eEP7fFb%23DHA.3496@TK2MSFTNGP10.phx.gbl...
> 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?
> -------------------------------------------------
> 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()   //????????
>
>
>


0
kemmou (4)
2/23/2004 3:02:44 AM
Matrix 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?

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
0
Oleg
2/23/2004 8:16:48 AM
Reply:

Similar Artilces:

How do I set up a tickler file?
I need to be able to set up a tickler file where I can enter a name and discharge date then have the program automatically remind me to take an action in 2 months. I am using office pro 2003.I would like to do this in excel or outlook. Why not use Outlook's calendar function? -- Ken Russell kenrussellyourhat@optushome.com.au Remove yourhat to reply by e-mail .. "moe3rd" <moe3rd@discussions.microsoft.com> wrote in message news:BB1A0479-4242-4E05-8BFD-AAB264F948ED@microsoft.com... >I need to be able to set up a tickler file where I can enter a name and > discha...

Query Delete and append
I am trying to add information to a table with an append query and that works fine since I duplicated the table. The information comes from a linked XLS sheet, I need to delete the information and replace it every day. When I created a delete query it works fine but when I try to add the information again using the append query it does not work unless I open the query in design view, save it and run it. I have dozens of other queries doing the same and they all work fine. What am I doing wrong? I looks like I am getting a 3349 error but why does it work once and then when I delete the ...

To get client data from a saved file back to the master file
I have designed a programme that records data and also links to another programme, but when I save the client information the name of the file changes and I loose the link. I want to be able to open a master copy each time and get the client data from the saved file so I can update each time and resave updates information, this way the link will always be there, I hope? ...

Run macro for each record in a query
Hello All I have a table [practices], which contains details of 'client organisations'. From time to time I need to send an email to certain 'client organisations'. I have a macro called 'send_emails' which uses the SendObject command, which I use to send the emails (a button on a form runs the macro). The emails include a report that is specific to the 'client organisation'. Currently I select the 'client organisation' with a combobox, run the macro, select another 'client organisation', run the macro again, etc. etc. It would be extrem...

output xml from xslt inC#
Hello, Thanks for taking the time to read. I'm begining Visual C# and trying to convert an HTML/Javascript application into a Windows application. I was using and XML database, transformed with XSL to output HTML, in Javascript for the client. Now, I have the same data in XML that I want to transform with XSL, but I need to output an XML node tree, to populate a treeView. I see a lot of ways to transform XML with XSL to output a string or a file, but I guess what I need is to output an XmlDocument I'm pretty confused with the "Writers" and "Readers" that ...

Count Records
Hi Guys, How can I count records in a a combobox to allow me to scroll using the slider bar without first having to scroll to the bottom of the list? Regards John Count the records in the rowsource of the combobox: NumRecord = DCount("*","NameOfTheRowSource") PC Datasheet Providing Customers A Resource For Help With Access, Excel And Word Applications resource@pcdatasheet.com "John" <johnlee2509@btopenworld.com> wrote in message news:0E1DBE7E-AD54-4715-A547-EC2DDE9CDE39@microsoft.com... > Hi Guys, > How can I count records in a a combobox...

office 2007 will not load, missing file SKU011.CAB...Help!
can not install MS Office Standard 2007, error message states that file SKU011.CAB is missing. Previously did install on lap top (windows 7). Will not install on desk top (windows XP). Can someone help? Office 2007 requires at least XP with SP2. If that's not the problem, then take a look here: http://support.microsoft.com/kb/818234/en-us -- Herb Tyson MS MVP Author of the Word Bible Blog: http://word.herbtyson.com Web: http://www.herbtyson.com "Hoot" <Hoot@discussions.microsoft.com> wrote in message news:98013A41-0F20-4CA6-A31D-68C57B3D5967@mic...

Appending worksheets
Hello, I have a huge workbook with some 200 worksheets (Excel 2002) and wouldlike to create one single worksheet by appending the data on all worksheets one after another. Is there an easy way to do this without programming a macro? Thanks so much. Provided the total data rows do not exceed 65535 (assuming a standard top row for col labels), one way would be sequential manual copy > paste into a single new sheet placed to the left of the 200 source sheets. At an est 15 sec per manual op, 200 sheets would only take roughly an hour of work to accomplish. Thereafter, to clean up, jus...

replacing text in all cells with existing text plus something
Hi, I have a sheet with several rows and columns containing text. I would like to add similar text to all the cells after the existing text. Is there an easy way to do that? thanks ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/office/commu...

Open outlook2K files in Outlook2003
I've upgraded from Outlook2000 to Outlook2003 on a WindowsXP with 2 Gig memory. The personal folders opened fine. I used "file" to open the other *.pst files. I managed to open 2 other old *.pst files. At that point , the error message "out of memory comes up and I can neither open any of the folders or even close any of the folders. Any suggestions would be highly appreciated. Best Regards John A Hansen John A Hansen <jahansen6@comcast.net> wrote: > I've upgraded from Outlook2000 to Outlook2003 on a WindowsXP with > 2 Gig memory. > > The person...

How to migrate E5.5 to E2K if new server was not installed in existing site
I'm taking over a network where the admin installed a new exchange 2000 server without adding it to the site of the existing exchange 5.5 server. So far, the posts I have read have mentioned installing the new server into the existing site. The new server already has a number of users on it. Also, the exchange 2000 attributes do not appear in active directory. Thanks for your help NH Hi Ned Did it install into the same organization, so you see 2 sites or administrative groups when you look in Exchange System Mgr or Exchange Administrator. Or do you not see both sites? This is possib...

Append and Append To priviliges
Anybody know what these two priviliges do for a record?? Jay Append allows a user to be able to add items to an object for example you can append an address to an account. Append to allows a user to append this object to something else. You would need append to priv on the address object. They work together. "Jay Mehta" <jay.mehta@conexio.com> wrote in message news:b6caea5f.0310311043.682d756c@posting.google.com... > Anybody know what these two priviliges do for a record?? > > Jay So, in the example you gave of appending an Address object to an Account object,...

Reading archived file
Newbie here. In trying to open a backed-up file (*.pst) from inside Outllok 2003, I get an error message that "file access is denied." I made the stupid backup. How can I get this file to open? Any ideas? >-----Original Message----- >Newbie here. In trying to open a backed-up file (*.pst) >from inside Outllok 2003, I get an error message >that "file access is denied." I made the stupid backup. >How can I get this file to open? Any ideas? >. > You didn't mention what media you saved this backup on but one possible reason that's ha...

File Permission Error
From time to time when I close Outlook XP, the following message appears: "Normal cannot complete the Save due to a File Permission error (c:\docs & settings\...\normal.etc)" This has only recently started happening, and I don't know how it could have been caused. I have searched the kb but nothing quite like this appears there. Any help/ideas would be most appreciated. Many thanks, Lawrence Oh well larry, I guess u r out of luck! A few more details would be nice, but try copying your normal.dot to a new file, and just create a blank .doc file and rename to .dot . Ma...

cannot delete record...
hi, i have received an error when i tried to delete a closed invoice; "the record cannot be deleted because it is read-only" any ideas? Do you have permissin to delete? "Orkun Goze" <orkung@nospam.mostint.com> wrote in message news:OtgRKZioDHA.1672@TK2MSFTNGP09.phx.gbl... > hi, > i have received an error when i tried to delete a closed invoice; "the > record cannot be deleted because it is read-only" > any ideas? > > Yes Darrin. I am the system admin. "Darrin Bishop" <dbishop@lrs.no.sp.am.com> wrote in message news:eI...

Using form to add record to table where records are limited by lis
Hi all... Bit hard to explain what I am doing here but I'll have a go :-) In Excel if I want to limit the number of records shown in rows I apply a filter for example to col1 which reduces all remaining cols. Then filter on col2 to reduce further etc etc until I have only a few records left to look at. I want to do this in access on a form BUT... I want to create a table of records that has an ID, Date stamp, a part number, qty I want this table to get its information from a form. I want the form to use a master table which includes the "part number" from above but where ...

Recording annual leave
I notice that there are some excellent sample timesheets out there (eg, Walkenbach and McRitchie). I was wondering if there is anything similar which would enable me to keep track of my annual leave? MS has an Employee Absence XL file at: http://officeupdate.microsoft.com/TemplateGallery/templates/6/tp1268.asp?i=3&l=1099,930,944,1268,1560,1269,1266,1454,1267,919,931,1435,408,518,289,288,&RC=4&M=16&mh=20&qu=&ct=&cid=0.75.77 -- Greeting from the Gulf Coast! http://myweb.cableone.net/twodays "C Tate" <colin@nobodyhere.mrcrtate.fsnet.co.uk> wrote in...

Can we set the UI color scheme via VB[A} or XML?
Does anyone know a way to set the color scheme for the UI, using VB[A} or XML? Can this even be done? Thanks -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc Sorry for not qualifying the Excel version. It's v12 or higher. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc ...

XML format enforcement
I wish to write some kind of XML format enforcer like DTD, XSD or other that can do the following: (1) Any element and node must have Type attribute that can be read as data type by the parser. (1) Any element and node may have (optional) four more attributes. I XML enforcer should allow any tree structure and any number of nodes in any tree. Does anyone can tell how it's possible? Any example will be most appreciated. -- Thanks Sharon Sharon wrote: > I wish to write some kind of XML format enforcer like DTD, XSD or other that > can do the following: > (1) Any element a...

Displaying a file in Excel.
I have a client that opens a file in excel. We are unable to view the file in normal view. We can see the file is we go to print preview or full screen mode. How can i change it to view in normal screen mode? First try Window>Arrange to see if it off-screen. If no joy try the usual fix for this problem. Tools>Options>General Uncheck "Ignore Other Applications" If no joy with that................ Close Excel first and On the Windows Taskbar 1) Start>Run "excel.exe /unregserver"(no quotes)>OK. 2) Start>Run "excel.exe /regserver"(no quote...

Outlook 2007 does not work after importing from another pst file
I installed Vista Ultimate and am running Office 2007 Enterprise. All updates done. I imported my old .pst file from my previous XP Pro installation (copied it to the new hard drive). Since the import I cannot get Outlook to react to the cursor and have to close it down via Task Manager. Any help appreciated. Trevor As posted many times on this forum, you must not Import pst files because importing can corrupt them. Copy the pst to your hard drive without overwriting any outlook files. Then use File, Open OL Data File to open and use it. "Trevor" wrote: > I insta...

MX record question #2
I have one windows 2003 and one exchange on the same server need to receive the email from Internet. Did I need to setup a MX record in my own DNS server point to my own server. Or only need to add a MX record in the ISP to point to my server Internet IP address ? or both needed? thanks in advice. lamlam wrote: > I have one windows 2003 and one exchange on the same server need to > receive the email from Internet. Did I need to setup a MX record in > my own DNS server point to my own server. Or only need to add a MX > record in the ISP to point to my server Internet IP addre...

Problem Importing a TXT File
I have a workbook named 05-03-31. It contains information for the first quarter of this year. Sheet 1 references cells on Sheet 2. Sheet 2 was created by importing a TXT file. I thought I had accomplished something wonderful at that time. I now have a new TXT file with second quarter data. I opened the first quarter workbook, 05-03-31 and saved it as 05-06-30, so now I have a second quarter workbook. When I Import the second quarter TXT file into the second quarter workbook it creates a Sheet 3. On Sheet 1 can I globally change all the references to Sheet 2 to Sheet 3? I tried deleting Sheet 2...

Preventing duplicate records
The title sounds deceptively easy to solve, but I can't figure out how to make a table refuse to allow a new record that doesn't duplicate a combination of fields. I already have a primary key (autonumber) and a date and a location field. The ID field can't be duplicated, but it's ok for the date OR for the location to be duplicated. However, it is NOT ok for the combination of the date and the location to be entered. Any ideas how to implement that constraint? Thanks, Gina Use a unique index on the combination of the date + location. 1. Open the table in design view....

Unlock new records?
Hi. I have a form that I am trying to protect from accidental changes. I used the code from Allen Browne's tip sheet "Locking bound controls" at http://allenbrowne.com/ser-56.html. It works perfectly. However, I would prefer each individual record to always stay locked unless a user clicks on the cmdLock button. I would also like for the record to lock back automatically when a user exits the record. I accomplished this by putting the following line in the OnCurrent property instead of the OnLoad property: =LockBoundControls ([Form],True) This works great, too. Now to the prob...