Imports System.Xml
Imports System.IO
public class Test
public Shared Sub Main
Dim memory_stream As New MemoryStream()
Dim xml_text_writer As New XmlTextWriter(memory_stream, System.Text.Encoding.UTF8)
xml_text_writer.Formatting = Formatting.Indented
xml_text_writer.Indentation = 4
xml_text_writer.WriteStartDocument(True)
xml_text_writer.WriteStartElement("Employees")
MakeEmployee(xml_text_writer, "A", "A", 11111)
MakeEmployee(xml_text_writer, "B", "B", 22222)
MakeEmployee(xml_text_writer, "C", "C", 33333)
xml_text_writer.WriteEndElement()
xml_text_writer.WriteEndDocument()
xml_text_writer.Flush()
Dim stream_reader As New StreamReader(memory_stream)
memory_stream.Seek(0, SeekOrigin.Begin)
Console.WriteLine(stream_reader.ReadToEnd())
xml_text_writer.Close()
End Sub
Private Shared Sub MakeEmployee(ByVal xml_text_writer As XmlTextWriter, ByVal first_name As String, ByVal last_name As String, ByVal emp_id As Integer)
xml_text_writer.WriteStartElement("Employee")
xml_text_writer.WriteStartElement("FirstName")
xml_text_writer.WriteString(first_name)
xml_text_writer.WriteEndElement()
xml_text_writer.WriteStartElement("LastName")
xml_text_writer.WriteString(last_name)
xml_text_writer.WriteEndElement()
xml_text_writer.WriteStartElement("EmployeeId")
xml_text_writer.WriteString(emp_id.ToString)
xml_text_writer.WriteEndElement()
xml_text_writer.WriteEndElement()
End Sub
End class
A
11111
B
22222
C
33333