modify value into XML file

  • Thread starter Thread starter Maileen
  • Start date Start date
M

Maileen

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
 
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top