XElement.SetElementValue sets the value of a child element, adds a child element, or removes a child element.
Imports System
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim root As XElement = <Root/>
root.SetElementValue("Ele1", 1)
root.SetElementValue("Ele2", 2)
root.SetElementValue("Ele3", 3)
Console.WriteLine(root)
root.SetElementValue("Ele2", 22)
Console.WriteLine(root)
root.SetElementValue("Ele3", Nothing)
Console.WriteLine(root)
End Sub
End Class
Related examples in the same category