- Joined
- Oct 23, 2004
- Location
- Hillbillyville
Hey yall.
I need to be able to find a line in an XML file and change its value to something else.
I found this section of code that ALMOST worked:
My problem is the XML files I'm trying to read from have their 'valuenodes' as <key name="something"> instead of just <key>
So I need to change the value in: //macros/macro/Block/Key-Value/Key name="PatternNames" but it says it has an invalid token.
If I just try to change .../key, it changes the first entry in that list. How can I reference the other nodes/values/ whatever?
Thanks for the help
I need to be able to find a line in an XML file and change its value to something else.
I found this section of code that ALMOST worked:
Code:
imports system.xml
...
Dim loXMLDoc As XmlDocument = New XmlDocument
Dim loNode As XmlNode
loXMLDoc.Load("C:\Path\To\Document.xml")
loNode = loXMLDoc.SelectSingleNode("//ParentNode/ChildNode1/ValueNode2")
loNode.InnerText = "UpdatedMoreData"
loXMLDoc.Save("C:\Path\To\Document.xml")
loNode = Nothing
loXMLDoc = Nothing
My problem is the XML files I'm trying to read from have their 'valuenodes' as <key name="something"> instead of just <key>
So I need to change the value in: //macros/macro/Block/Key-Value/Key name="PatternNames" but it says it has an invalid token.
If I just try to change .../key, it changes the first entry in that list. How can I reference the other nodes/values/ whatever?
Thanks for the help