By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,259 Members | 1,709 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,259 IT Pros & Developers. It's quick & easy.

VB.Net Function to create xml string

P: 14
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 EmpId="3" EmpName="Cara">
<Emp EmpId="6" EmpName="Jenna" />
<Emp EmpId="7" EmpName="Mike" />
<Emp EmpId="8" EmpName="Tessa" />

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
Dim XmlString as String = et.root.GetXml()

Can someone help me with creating the GetXML() Function?
Nov 3 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.