I want to update a node in vb.net using xml but I cannot find a proper solution.
This is what I have for reading and writing:
If (IO.File.Exists(Application.StartupPath & "MyXML.xml")) Then
Dim document As XmlReader = New XmlTextReader("MyXML.xml")
While (document.Read())
Dim type = document.NodeType
If (type = XmlNodeType.Element) Then
If (document.Name = "port") Then
port = document.ReadInnerXml.ToString()
End If
End If
End While
Else
Dim settings As New XmlWriterSettings()
settings.Indent = True
Dim XmlWrt As XmlWriter = XmlWriter.Create("MyXML.xml", settings)
With XmlWrt
.WriteStartDocument()
.WriteComment("XML.")
.WriteStartElement("Data")
.WriteStartElement("Settings")
.WriteStartElement("port")
.WriteString("7008")
.WriteEndElement()
.WriteEndDocument()
.Close()
End With
End If