By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,078 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,078 IT Pros & Developers. It's quick & easy.

How to modify a xml record using asp.net Web Application?

P: n/a
I have a xml document created
<?xml version="1.0" standalone="yes" ?>
<Group>
<Information>
<ID>44</ID>
<Detail>Hello World</Detail>
</Information>
<Information>
<ID>45</ID>
<Detail>My Text</Detail>
</Information>
<Information>
<ID>46</ID>
<Detail>Text Information</Detail>
</Information>
</Group>

I want to know the codes to modify <Detail> according to the <ID>....
for example i enter
textbox1.text = 44
textbox2.text = texts

It can change
<ID>44</ID>
<Detail>Hello World</Detail>
to
<ID>44</ID>
<Detail> texts </Detail>

Are there any codes can do this?
thanks for help
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Addition

I want to search the ID first then modify the Detail...
Do i need to search the ID first then modify the value in <Detail> ?

Thanks for help
Allan
Nov 19 '05 #2

P: n/a
I found an article where you can update your XmlFile using the
DataSet.WriteXml method.

http://www.dotnethero.com/hero/xml/U...e.aspx?nmx=4_1

So, you could either use the a DataGrid like in the Article to find whith
record you're updating.
Or you can loop through your dataset finding the ID = 45, then updating your
detail
Followed by DataSet.WriteXml

HTH

"Allan A via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:53***********@DotNetMonster.com...
I have a xml document created
<?xml version="1.0" standalone="yes" ?>
<Group>
<Information>
<ID>44</ID>
<Detail>Hello World</Detail>
</Information>
<Information>
<ID>45</ID>
<Detail>My Text</Detail>
</Information>
<Information>
<ID>46</ID>
<Detail>Text Information</Detail>
</Information>
</Group>

I want to know the codes to modify <Detail> according to the <ID>....
for example i enter
textbox1.text = 44
textbox2.text = texts

It can change
<ID>44</ID>
<Detail>Hello World</Detail>
to
<ID>44</ID>
<Detail> texts </Detail>

Are there any codes can do this?
thanks for help

Nov 19 '05 #3

P: n/a
Pat
Allan you can also look at this Artice that Updates,Edit ad Insert at:-
http://aspnet.4guysfromrolla.com/articles/112603-1.aspx
Hope that helps
Patrick
"Allan A via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:53***********@DotNetMonster.com...
Addition

I want to search the ID first then modify the Detail...
Do i need to search the ID first then modify the value in <Detail> ?

Thanks for help
Allan

Nov 19 '05 #4

P: n/a
Thanks for help! The sample help me a lot!
but there is another problem...

Dim i As Integer
Dim ds As New DataSet
Try
'Refill the dataset
ds.ReadXml(Server.MapPath("Information.xml"))
'Make the Updates
For i = 1 To ds.Tables(0).Rows.Count

If ds.Tables(0).Rows(i).Item("ID") = txtInputID.Text Then
lbl.Text = "Update record"
Else
lbl.Text = "No match record"
End If
Next

Catch
'Redirect to Error Page or take other action to handle error.
Finally
ds.Dispose()
End Try

it did not have response, if
ds.Tables(0).Rows(0).Item("JobID") = txtInputJobID.Text Then
it can only find the first record in the xml doc

is the code wrong?

thanks
Allan
I have a xml document created
<?xml version="1.0" standalone="yes" ?>
<Group>
<Information>
<ID>44</ID>
<Detail>Hello World</Detail>
</Information>
<Information>
<ID>45</ID>
<Detail>My Text</Detail>
</Information>
<Information>
<ID>46</ID>
<Detail>Text Information</Detail>
</Information>
</Group>

I want to know the codes to modify <Detail> according to the <ID>....
for example i enter
textbox1.text = 44
textbox2.text = texts

It can change
<ID>44</ID>
<Detail>Hello World</Detail>
to
<ID>44</ID>
<Detail> texts </Detail>

Are there any codes can do this?

thanks for help

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200508/1
Nov 19 '05 #5

P: n/a
Allan

I know what is wrong. Thanks for your help again!
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200508/1
Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.