XmlDocument.CreateElement creates an element with the specified Prefix, LocalName, and NamespaceURI.
Imports System
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
Dim xmlData as string = "<book xmlns:bk='urn:samples'></book>"
doc.Load(new StringReader(xmlData))
Dim elem as XmlElement = doc.CreateElement("bk", "genre", "urn:samples")
elem.InnerText = "asdf"
doc.DocumentElement.AppendChild(elem)
doc.Save(Console.Out)
end sub
end class
Related examples in the same category