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

Write to XML with C#

I am trying to collect and write some temporary data to xml file
before I put them into DB.

I am writing into xml file like follows:
private void WriteXML()
{
//Use the xmlTextWriter to open a new xml file
XmlTextWriter writer = new
XmlTextWriter(@"C:\\Data\\tblPomocnaTablica.xml",
System.Text.Encoding.UTF8);

//Write the root element
writer.WriteStartElement("tblTableX");

// Write the elements
writer.WriteElementString("ClientID", "2");
writer.WriteElementString("EmployeeID", "4");
writer.WriteElementString("ShopID", "100");
writer.WriteElementString("ProductID", "100");
writer.WriteElementString("Qty", "1");
// end the root element
writer.WriteEndElement();
// Flush
writer.Flush();
//Write the XML to file and close the writer
writer.Close();
}
It is works and I get something like this:
ClientID | EmployeeID | ProdavonicaID | ProductID | Qty |
2 | 4 | 100 | 100 |1 |
Two Questions
1) How I can write a new rows without rewriting existing rows,
for e.g.?
2 | 4 | 124 | 25 |1 |
etc.

Result should be something like this:
ClientID | EmployeeID | ProdavonicaID | ProductID | Qty |
------------------------------------------------------------------------
2 | 4 | 100 | 100 |1 |
2 | 4 | 124 | 25 |1 |

2) How I can change one value in some row, for e.g.
row 2 ShopID = 250, is that possible?
Thanks in advance
Mike
Oct 27 '07 #1
3 1426
Why not just store the information in some temporary tables inside the
database and move them to the final tables later?

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"Mike" <ab******@yahoo.comwrote in message
news:g3********************************@4ax.com...
>I am trying to collect and write some temporary data to xml file
before I put them into DB.

I am writing into xml file like follows:
private void WriteXML()
{
//Use the xmlTextWriter to open a new xml file
XmlTextWriter writer = new
XmlTextWriter(@"C:\\Data\\tblPomocnaTablica.xml",
System.Text.Encoding.UTF8);

//Write the root element
writer.WriteStartElement("tblTableX");

// Write the elements
writer.WriteElementString("ClientID", "2");
writer.WriteElementString("EmployeeID", "4");
writer.WriteElementString("ShopID", "100");
writer.WriteElementString("ProductID", "100");
writer.WriteElementString("Qty", "1");
// end the root element
writer.WriteEndElement();
// Flush
writer.Flush();
//Write the XML to file and close the writer
writer.Close();
}
It is works and I get something like this:
ClientID | EmployeeID | ProdavonicaID | ProductID | Qty |
2 | 4 | 100 | 100 |1 |
Two Questions
1) How I can write a new rows without rewriting existing rows,
for e.g.?
2 | 4 | 124 | 25 |1 |
etc.

Result should be something like this:
ClientID | EmployeeID | ProdavonicaID | ProductID | Qty |
------------------------------------------------------------------------
2 | 4 | 100 | 100 |1 |
2 | 4 | 124 | 25 |1 |

2) How I can change one value in some row, for e.g.
row 2 ShopID = 250, is that possible?
Thanks in advance
Mike
Oct 28 '07 #2
Is that a proper way to resolve that?

On Sat, 27 Oct 2007 18:02:09 -0600, "Andrew Faust"
<an****@andrewfaust.comwrote:
>Why not just store the information in some temporary tables inside the
database and move them to the final tables later?
Oct 29 '07 #3
Why wouldn't it be? You have data to store and you have a database. Seems
like a match made in heaven.

Just so we're clear, I wasn't proposing you create a table on the fly, use
it for a while and then destroy it. I was proposing you create a table (or
tables) as part of your design that you always use for this temporary
storage. You can delete the records after you've moved them to the final
table and keep reusing the table.
--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"Mike" <ab******@yahoo.comwrote in message
news:jd********************************@4ax.com...
Is that a proper way to resolve that?

On Sat, 27 Oct 2007 18:02:09 -0600, "Andrew Faust"
<an****@andrewfaust.comwrote:
>>Why not just store the information in some temporary tables inside the
database and move them to the final tables later?
Oct 30 '07 #4

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

Similar topics

10
by: Greg Hurlman | last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying to write out 4 fields from a recordset in succession: Response.Write rs("LastName") Response.Write rs("Suffix")...
1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
0
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
8
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
11
by: Vmusic | last post by:
Hi, I am trying to write out an array of string variables to Notepad. I can't get SendKeys to accept the string variable only literal quoted strings. I DO NOT want the hassle of writing to a...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
0
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
8
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.