Imports System
Imports System.Xml
Class MainClass
Public Shared Sub Main(ByVal args As String())
Dim doc As XmlDocument = New XmlDocument
Dim root As XmlNode = doc.CreateElement("all")
doc.AppendChild(root)
Dim i As Integer 'YOU OLDIE, USE CLEAR VARNAMES! WE DON'T LIVE IN THE STONEAGE WHERE SHORT VARNAMES WHERE NEEDED ANYMORE
For i = 1 To 5
Dim elm As XmlNode = doc.CreateElement("one")
elm.AppendChild(doc.CreateTextNode("Element #" & i))
root.AppendChild(elm)
Next
doc.InsertBefore(doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"), doc.DocumentElement)
doc.Save("C:\test2.xml")
End Sub
End Class
Output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<all>
<one>Element #1</one>
<one>Element #2</one>
<one>Element #3</one>
<one>Element #4</one>
<one>Element #5</one>
</all>