473,810 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

writing to XML file

I'm struggling with what should be a very basic .aspx/XML issue. I
have an XML file. I have a textbox for a user to enter data and a
button to submit the data. I don't wont the user to see the other
records on the screen. I'm using Visual Web Developer Express 2005,
vb.NET) I've tried several different strategies from books and online
examples, but I can't seem to get anywhere. I'm guessing I need to Dim
a DataSet (even though I'm adding only one record). Of course I need
to pass the value of my textbox into the XML file via an event handler
on the button's code. Should I embed and INSERT query string into the
button's click event? Please any advice would be appreciated. Thanks!

Jun 11 '07 #1
5 1516
On Jun 11, 9:39 pm, slinky <campbellbrian2 ...@yahoo.comwr ote:
I'm struggling with what should be a very basic .aspx/XML issue. I
have an XML file. I have a textbox for a user to enter data and a
button to submit the data. I don't wont the user to see the other
records on the screen. I'm using Visual Web Developer Express 2005,
vb.NET) I've tried several different strategies from books and online
examples, but I can't seem to get anywhere. I'm guessing I need to Dim
a DataSet (even though I'm adding only one record). Of course I need
to pass the value of my textbox into the XML file via an event handler
on the button's code. Should I embed and INSERT query string into the
button's click event? Please any advice would be appreciated. Thanks!
http://groups.google.com/group/micro...a2d758049b3744

Jun 11 '07 #2
No disrespect, but I went to that site and did not find anything
pertinent to the needs of this very simple (for everyone but us
newbies) request. Does anyone else know of some basic structure
relative to the specific questions of my base post? Thanks!
>On Jun 11, 3:59 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :


Jun 11 '07 #3

There are kinda 2 ways you can go about this:

Treat your xml as a XmlDocument

that would involve you writing Xpath statements to find data.
And would return XmlNodeList objects.

OR

Treat your backend data as a DataSet ( a strongly typed one would be
better).
However, to do this, the xml has to be in a specific format. (DataSet
friendly).
I would suggest this:

Create your own strong dataset object.

Right click / Add New Item (DataSet)
Call it "MyFirstDataSet ".

Add a table in the designer. (if youre in 2.0 , DELETE the table adapter
that gets auto created at the bottom)

Add a table like "Employee"

add columns like "SSN" , "LastName" , "FirstName" .
MyFirstDataSet ds = new MyFirstDataSet( );
ds.Employee.Add NewEmployeeRow ( "222222222" , "Smith" , "John" ) ;
ds.Employee.Add NewEmployeeRow ( "333333333" , "Jones" , "Mary" ) ;

ds.WriteXml (@"C:\myds.xml" );

...............

There is a ReadXml method as well.
IF you do this, you'll see how the xml is formed, when you open the file in
notepad.

Then you can do stuff like

MyFirstDataSet ds = new MyFirstDataSet( );
ds.ReadXml(@"C: \myds.xml");

ds.Employee.Sel ect ("SSN='22222222 2'");

well, you gotta figure out what the above returns, and get a ref to it.

The above should return 1 DataRow (I think?) and you'll be able to cast it
as a
MyFirstDataSet. EmployeeRow object.
Something like that.
If you go with a pure XmlDocument model, you'll have to learn some Xpath.
If you want to go with a DataSet route, AND you don't have dataset friendly
Xml to begin with, you can do this:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!148.entry
...

"slinky" <ca************ ***@yahoo.comwr ote in message
news:11******** **************@ u2g2000hsc.goog legroups.com...
I'm struggling with what should be a very basic .aspx/XML issue. I
have an XML file. I have a textbox for a user to enter data and a
button to submit the data. I don't wont the user to see the other
records on the screen. I'm using Visual Web Developer Express 2005,
vb.NET) I've tried several different strategies from books and online
examples, but I can't seem to get anywhere. I'm guessing I need to Dim
a DataSet (even though I'm adding only one record). Of course I need
to pass the value of my textbox into the XML file via an event handler
on the button's code. Should I embed and INSERT query string into the
button's click event? Please any advice would be appreciated. Thanks!

Jun 11 '07 #4

"slinky" <ca************ ***@yahoo.comwr ote in message
news:11******** *************@q 69g2000hsb.goog legroups.com...
No disrespect, but I went to that site and did not find anything
pertinent to the needs of this very simple (for everyone but us
newbies) request. Does anyone else know of some basic structure
relative to the specific questions of my base post? Thanks!
Please scroll the page down, the code you've posted is more or less correct,
you just need to modify a few things
Jun 11 '07 #5
Thanks! I've kinda got some script below that I'm hoping to make work.
I will have a textbox (txtEvent) that I've added to hold the value for
which my submit button will write as a new "record" to the XML file.
I'm guessing I need a SELECT INTO sql query in there somewhere for
adding the record? Any help would be appreciated. Thanks!

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim myDataSet As New DataSet()
myDataSet.ReadX ml(Server.MapPa th("timeline.xm l"))
txtNewEvent.Dat aBind()
End Sub

Protected Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.EventArg s)
myDataSet.DataS et.WriteXml(Ser ver.MapPath("ti meline.xml"))
End Sub
There is a ReadXml method as well.
IF you do this, you'll see how the xml is formed, when you open the file in
notepad.
Then you can do stuff like
MyFirstDataSet ds = new MyFirstDataSet( );
ds.ReadXml(@"C: \myds.xml");
ds.Employee.Sel ect ("SSN='22222222 2'");
well, you gotta figure out what the above returns, and get a ref to it.
The above should return 1 DataRow (I think?) and you'll be able to cast it
as a
MyFirstDataSet. EmployeeRow object.
Something like that.
Jun 12 '07 #6

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

Similar topics

48
8519
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential problem. The program may crash unexpectedly while writing to the file. If so, my program should detect this during startup, and then (during startup) probably delete the data added to the file and redo the writing operation.
6
23610
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
3
3409
by: ishekar | last post by:
Hi, I have an application where i want to write data to a file, the data is being sent from an external source. I know the total size of the data and then i retrieve the data in small segments from the source. This data is written to file in a loop. My question. 1. Will it be useful to increase the file size initially then seek to 0 and start writing to file. whether there will be any performance improvements
1
717
by: Daniel | last post by:
System.IO.StreamWriter Close or Flush method to shut down the computer in such a way that just part of the file is written? or an empty file is written? Also if the Close or Flush is to a streamwriter writing to a network share, is it possible for the network to go down in such a way that the tartet file is only partialy written? or are there some kind of check sums to prevent this.
2
6863
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to replace just one item. I know I can get the entire array, then save the whole thing (with a for loop and if statements so that the changed data will be saved), but it seems like a lot of unnecessary reading and writing. Is there a way to directly save...
4
2181
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will write the information about user name, filename upload, filesize, date and time of uploading into the log file. (The name of the log file is constructed by Current Year and Current Month in my program). Is there any problems with writing into the...
0
1721
by: Yunus's Group | last post by:
Yunus's Group May 23, 3:36 pm show options Newsgroups: microsoft.public.dotnet.languages.vb From: "Yunus's Group" <yunusasm...@gmail.com> - Find messages by this author Date: 23 May 2005 12:36:14 -0700 Local: Mon,May 23 2005 3:36 pm Subject: Writing to text file Reply | Reply to Author | Forward | Print | Individual Message | Show original | Remove | Report Abuse
16
7193
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain unchanged). How can I do that in Python? Claudio Grondi
6
5278
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
3
2699
by: Barry Flynn | last post by:
Hi I am working with a VB 2005 program which has been converted from VB6. It writes data out to a flat file, with code like the following line WriteLine(riFileNo, "Hist", lsAssetID, lsRecordType, lsXNbr, lsFiscYr, "Beg", CStr(H.BegBalAccDepn), CStr(H.BegBalCost), CStr(H.BegBalCostReval), CStr(H.BegBalDepCost), CStr(H.BegBalDepnReval)) The program is running from within a Virtual PC
0
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
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
10393
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
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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
6882
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
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
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
3015
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.