VB.Net Function to create xml string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srkidd12
    New Member
    • Jan 2008
    • 14

    VB.Net Function to create xml string

    We are trying to generate the following XML on a client machine:

    <Emp EmpId="1" EmpName="Ann">
    <Emp EmpId="2" EmpName="Bob">
    <Emp EmpId="4" EmpName="Dave" />
    <Emp EmpId="5" EmpName="Frank" />
    </Emp>
    <Emp EmpId="3" EmpName="Cara">
    <Emp EmpId="6" EmpName="Jenna" />
    <Emp EmpId="7" EmpName="Mike" />
    <Emp EmpId="8" EmpName="Tessa" />
    </Emp>
    </Emp>


    The data below contains the Employee Ids (EmpId), Employee Names (EmpName), and Supervisors Employee Id (SupId) to be used in the XML output.

    EmpId EmpName SupId
    1 Ann 0
    2 Bob 1
    3 Cara 1
    4 Dave 2
    5 Frank 2
    6 Jena 3
    7 Mike 3
    8 Tessa 3
    * When an employee does not have supervisor, SupId is set to 0.

    Public Class ‘emp’ shown here has already been written to store the data hierarchically and generate the needed Xml string.
    Public Class emp
    Public EmpID As Integer
    Public EmpName As String
    Public SupID As Integer
    Public EmpList As List(Of emp)
    Public Function GetXml() As String

    Public Class ‘EmpTree’ shown here has already been written and contains sub ‘BuildTree’ which will read all Employee data and create hierarchical data structure in root.
    Public Class EmpTree
    Public root As emp
    Public Sub BuildTree()

    Client program code shown here has already been written to generate the XML string.
    Dim et As New EmpTree
    et.BuildTree()
    Dim XmlString as String = et.root.GetXml( )


    Can someone help me with creating the GetXML() Function?
Working...