473,473 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add multiple records to xml file

81 New Member
Hi,
Expand|Select|Wrap|Line Numbers
  1.         xmlw = new XmlTextWriter("c:\\testing.xml",null);
  2.             xmlw.WriteStartDocument();
  3.             xmlw.WriteStartElement("Company");
  4.             xmlw.WriteStartElement("Software");
  5.             xmlw.WriteStartElement("Skills");
  6.             xmlw.WriteElementString("Microsoft", textBox1.Text);
  7.             xmlw.WriteElementString("Sun", textBox2.Text);
  8.             xmlw.WriteEndElement();
  9.             xmlw.WriteStartElement("Management");
  10.             xmlw.WriteElementString("Admin", textBox3.Text);
  11.             xmlw.WriteElementString("Assist", textBox4.Text);            
  12.             xmlw.WriteEndElement();
  13.             xmlw.WriteEndElement();
  14.             xmlw.WriteEndElement();
  15.             xmlw.WriteEndDocument();
  16.             xmlw.Close();
  17.  
The above code is for creating an xml, its working fine now iam having two requirements based on above code
1)after writing (xmlw.Close()) xml i want to display that xml in text box
2) I want to add multiple records in that xmlfile bcoz it creatinng only one record then we added another record means its replacing the previous record
I want to add multiple records in xml how?
Jul 17 '08 #1
3 5059
acoder
16,027 Recognized Expert Moderator MVP
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

MODERATOR.
Jul 20 '08 #2
acoder
16,027 Recognized Expert Moderator MVP
The above code is for creating an xml, its working fine now iam having two requirements based on above code
1)after writing (xmlw.Close()) xml i want to display that xml in text box
2) I want to add multiple records in that xmlfile bcoz it creatinng only one record then we added another record means its replacing the previous record
I want to add multiple records in xml how?
This is not an XML question really. This will be better answered in a language-specific forum (.NET I presume).
Jul 20 '08 #3
jkmyoung
2,057 Recognized Expert Top Contributor
1. Questions:
Do you really need to save the xml in a file, as opposed to some runtime memory object, perhaps as a string even?

If so, you could onClose, create a function which reads the text from the xml file and puts it into the textBox. However this seems like more work than necessary. It'd be easier if you had your XmlTextWriter write to a stringBuffer or stream, and then output the string to both the xml file and the textBox.

2. You need to create a function to read the xml you've written, eg an XmlReader.
After reading the xml in, you'd have a loop that rewrites the data to the new result as it reads it in from the old. Event style input/output is definitely the way to go, (eg the way you already have it by using XmlTextWriter). DOM would be overkill.
Jul 21 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: googlinggoogler | last post by:
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one...
7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
1
by: Charlie | last post by:
Hello, I have data in an Access table that I would like to export to multiple HTML tables. I would like to split the data in the Access table (about 92,000 records) into multiple HTML...
1
by: ccr | last post by:
Please view in a text editor so that the columnar text lines up. I used Terminal 9pt font to compose this post and copied/pasted to my newsreader program. I am writing in the hope that one of...
1
by: ccr | last post by:
Reposted with a longer line length. Apologies if I did not cancel the 1st attempt before you got it. If necessary, please view in a text editor so the columnar text lines up. I used Terminal...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
by: JenHu | last post by:
Hi experts, I wrote a function which retrieves a file in the folder, the file path is : Dim sr As New StreamReader(strFilepath & ReturnFileName) What if I have more than 1 file_name in...
18
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site...
5
by: Kaur | last post by:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two...
43
by: bonneylake | last post by:
Hey Everyone, Well this is my first time asking a question on here so please forgive me if i post my question in the wrong section. What i am trying to do is upload multiple files like gmail...
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...
1
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...
1
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...
0
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...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.