Dim MyXML As New XmlDocument()
Dim filename As String = "C:\ObrXMLFile.xml"
MyXML.Load(filename)
Dim MyXMLNode As XmlNode = MyXML.SelectSingleNode("/configuration/dl_cf")
If MyXMLNode IsNot Nothing Then
MyXMLNode.Attributes("value").Value = cbTxFreq.Text
' MyXMLNode.ChildNodes(8).InnerText = "dl_cf=" & "int" & " value=" & "newval"
End If
' Save the Xml.
MyXML.Save("C:\ObrXMLFile.xml")
MCSD - 2014
MCSA
-----------------------
If your query resolves by my suggestion/help, please mark my reply as answer, that will help community .
None
0 Points
3 Posts
updating XML Child
Aug 29, 2014 01:01 PM|Crestcon|LINK
I'm hoping that someone can point me in the right direction.
I have been searching for a way to update a value in a child node but have been unable to find a way that fits the format of the XML file.
In the example below, I need to update the value in childnode(8) from value="341000" to what has been selected from a comboBox "cbTxFreq.Text".
The best I have been able to do is to append data to the childnode.
Is there a method to simply update the Value and save it?
I'm using VB.Net 2008
Thanx in advance
___________________________________________________________________
XML SAMPLE
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<digital type="bool" value="false" />
<dl_map_timer type="int" value="50" />
<pilot_fix type="bool" value="true" />
<adpt_mod type="bool" value="true" />
<broadcast_modulation type="string" value="bpsk_12" />
<cell_radius type="float" value="50" />
<chnl_bw type="float" value="3.5" />
<cyc_prfx type="float" value="0.25" />
<dl_cf type="int" value="3410000" />
</configuration>
____________________________________________________________
Dim MyXML As New XmlDocument()
Dim filename As String = "c:\ObrXMLFile.xml"
MyXML.Load(filename)
Dim MyXMLNode As XmlNode = MyXML.SelectSingleNode("/configuration")
If MyXMLNode IsNot Nothing Then
MyXMLNode.ChildNodes(8).InnerText ="dl_cf=" & "int" & " value=" & cbTxFreq.Text
End If
' Save the Xml.
MyXML.Save("c:\ObrXMLFile.xml")
Member
610 Points
286 Posts
Re: updating XML Child
Aug 29, 2014 01:46 PM|arindamnayak|LINK
I have tried this and it is working.
MCSA
-----------------------
If your query resolves by my suggestion/help, please mark my reply as answer, that will help community .
None
0 Points
3 Posts
Re: updating XML Child
Aug 29, 2014 02:24 PM|Crestcon|LINK
Works very nice indeed. Thanx
Could you sugest how to use this form to update multipul ChildNodes that fall under the "/configuration" as in the example.
Dim MyXMLNode As XmlNode = MyXML.SelectSingleNode("/configuration")
If MyXMLNode IsNot Nothing Then
MyXMLNode.dl_cf.Attributes("value").Value = cbTxFreq.Text
MyXMLNode.chnl_bw.Attributes("value").Value = cbBW.Text
end if
or somthig like that.
Being new to XML I'm still having problems with proper formating.
Member
610 Points
286 Posts
Re: updating XML Child
Aug 29, 2014 02:27 PM|arindamnayak|LINK
yes, you have to select each of nodes like
and then update values using attribute.
If this helps, please mark this as answer.
MCSA
-----------------------
If your query resolves by my suggestion/help, please mark my reply as answer, that will help community .
None
0 Points
3 Posts
Re: updating XML Child
Aug 29, 2014 02:30 PM|Crestcon|LINK
That help a great deal.
thanx again
Member
610 Points
286 Posts
Re: updating XML Child
Aug 29, 2014 02:39 PM|arindamnayak|LINK
Can you mark , my reply as answer, that will be great help!
MCSA
-----------------------
If your query resolves by my suggestion/help, please mark my reply as answer, that will help community .