469,631 Members | 1,304 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

modify value into XML file

Hi,

I've asked yesterday if someone already modify data into XML file using
VB.NET.

In fact, my XML file is like that.

....
<DB>
<DB_Loc>
mytext
</DB_Loc>
</DB>
<SETTINGS>
....
</SETTINGS>
....

I would like to modify my text "mytext" and replace it by some other value.

How can I do this ?
thanks,
Maileen
Nov 21 '05 #1
3 12820
Hi Maileen

Without testing...

Dim d As New System.Xml.XmlDocument
d.LoadXml("<DB><DB_Loc>mytext</DB_Loc></DB>")
Dim n As System.Xml.XmlNode = d.SelectSingleNode("//DB/DB_Loc") ' your
example implies that DB is not the root element...
n.InnerText = "A new value"
d.Save("C:\test.xml")

HTH

Nigel Armstrong

"Maileen" wrote:
Hi,

I've asked yesterday if someone already modify data into XML file using
VB.NET.

In fact, my XML file is like that.

....
<DB>
<DB_Loc>
mytext
</DB_Loc>
</DB>
<SETTINGS>
....
</SETTINGS>
....

I would like to modify my text "mytext" and replace it by some other value.

How can I do this ?
thanks,
Maileen

Nov 21 '05 #2
but in your example, i don't load the XML source file
before...everything is done in memory.

before to modify data of node, I want to open the XML file and modify
directly to XML file the value.

Maileen

Nigel Armstrong wrote:
Hi Maileen

Without testing...

Dim d As New System.Xml.XmlDocument
d.LoadXml("<DB><DB_Loc>mytext</DB_Loc></DB>")
Dim n As System.Xml.XmlNode = d.SelectSingleNode("//DB/DB_Loc") ' your
example implies that DB is not the root element...
n.InnerText = "A new value"
d.Save("C:\test.xml")

HTH

Nigel Armstrong

"Maileen" wrote:

Hi,

I've asked yesterday if someone already modify data into XML file using
VB.NET.

In fact, my XML file is like that.

....
<DB>
<DB_Loc>
mytext
</DB_Loc>
</DB>
<SETTINGS>
....
</SETTINGS>
....

I would like to modify my text "mytext" and replace it by some other value.

How can I do this ?
thanks,
Maileen

Nov 21 '05 #3
I've discovered where was the mistake.
I don't know why, but VB wrote the changes into another folder than
where it should be done, so never my xml file was modified even if
folder and file variable where correct.

so code is good.
Maileen

Nigel Armstrong wrote:
Hi Maileen

Without testing...

Dim d As New System.Xml.XmlDocument
d.LoadXml("<DB><DB_Loc>mytext</DB_Loc></DB>")
Dim n As System.Xml.XmlNode = d.SelectSingleNode("//DB/DB_Loc") ' your
example implies that DB is not the root element...
n.InnerText = "A new value"
d.Save("C:\test.xml")

HTH

Nigel Armstrong

"Maileen" wrote:

Hi,

I've asked yesterday if someone already modify data into XML file using
VB.NET.

In fact, my XML file is like that.

....
<DB>
<DB_Loc>
mytext
</DB_Loc>
</DB>
<SETTINGS>
....
</SETTINGS>
....

I would like to modify my text "mytext" and replace it by some other value.

How can I do this ?
thanks,
Maileen

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Job Lot | last post: by
12 posts views Thread by Venkat | last post: by
2 posts views Thread by Elby | last post: by
4 posts views Thread by jp.delatorre | last post: by
5 posts views Thread by Alberto | last post: by
1 post views Thread by LB | last post: by
reply views Thread by nkw | last post: by
1 post views Thread by Joey | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.