-
XML Opening and Closing Elements
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
Similar Threads
-
Replies: 2
Last Post: 07-08-2005, 02:30 PM
-
By Luis E. Cuadrado in forum C++
Replies: 3
Last Post: 12-18-2001, 03:12 PM
-
By Luis E. Cuadrado in forum C++
Replies: 2
Last Post: 12-17-2001, 02:18 PM
-
By Shailesh Patel in forum VB Classic
Replies: 8
Last Post: 12-07-2001, 04:23 AM
-
By anonymous in forum VB Classic
Replies: 1
Last Post: 08-19-2001, 07:52 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|