On May 7, 5:59 pm, Martin Honnen <mahotr...@yahoo.dewrote:
yhl...@gmail.com wrote:
<MyProg>
<Path>test1</Path>
</MyProg>
I want to change the element Path to test2 instead of test1
How can I do that ? Is there a function which gets full xml path and
new value and change the element in this path?
Dim XmlDoc As XmlDocument = New XmlDocument()
XmlDoc.Load("file.xml")
XmlDoc.DocumentElement("Path").InnerText = "test2"
XmlDoc.Save("file.xml")
In general to find nodes you can also use XPath and the methods
SelectNodes and SelectSingleNode.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Hi
It's work! Thanks a lot.
Another problem:
if the xml is look like that:
<MyFile>
<elem1>
<elem2>test1</elem2>
</elem1>
</MyFile>
and I want to change the element elem2 which is son of elem1. How can
I do that?
I tried to do it in that way but it didn't work:
XmlDoc.DocumentElement("elem2").InnerText = "test2"
or
XmlDoc.DocumentElement("elem1/elem2").InnerText = "test2"
Thanks