Good Afternoon,

I'm creating an element with an attribute in an existing xml file name "Employees" and what it's doing in the file is this;

<Employees recordCount="1" />

What I want it to do is to wrap around the rest of the file like so;

<?xml version="1.0" standalone="yes"?>
<EmployeeLoad xmlns="http://tempuri.org/">
<Employees recordCount="1" >
<Employee>
<EmployeeID>12345</EmployeeID>
<LastName>Test</LastName>
<FirstName>Test</FirstName>
<MiddleName>P</MiddleName>
<HomeAirport_IATA>IAD</HomeAirport_IATA>
<CrewPosition>Tester</CrewPosition>
<Email>Test@gmail.com</Email>
<Gender>M</Gender>
<Department>0507J0</Department>
<AirlineCode_IATA>GG</AirlineCode_IATA>
<AirlineCode_ICAO>GGG</AirlineCode_ICAO>
<SupervisorEmployeeID />
</Employee>
</Employees>
</EmployeeLoad>


The code I'm using to do this is as follows:

'Insert Employees element to the xml file before Employee element
Dim root As XmlElement = XDoc.DocumentElement
Dim xmlEmployeeLoad As XmlElement = XDoc.CreateElement("Employees")
root.InsertBefore(xmlEmployeeLoad, root.FirstChild)

'Add record count to the Employees element
Dim dataNodes As XmlNodeList = XDoc.GetElementsByTagName("Employees")
If (Not dataNodes Is Nothing And dataNodes.Count > 0) Then
Dim a As XmlAttribute = XDoc.CreateAttribute("recordCount")
a.Value = intCount.ToString()
dataNodes(0).Attributes.Append(a)
End If

''Save to changes to the xml file
XDoc.Save(strFileName)


Any ideas would be greatly appreciated!

Thanks,

Jim