<xs:element name="ProductName" type="xs:string" minOccurs="0" msdata:Ordinal="1" />
<xs:element name="RetailPrice" type="xs:decimal" minOccurs="0" msdata:Ordinal="3" />
<xs:element name="Description" type="xs:string" minOccurs="0" msdata:Ordinal="4" />
</xs:sequence>
<xs:attribute name="ID" type="xs:int" />
<xs:attribute name="WholesalePrice" type="xs:decimal" use="prohibited" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<tblInventory ID="1">
<ProductName>Rubber Chicken</ProductName>
<RetailPrice>2.99</RetailPrice>
<Description>The quintessential rubber chicken.</Description>
</tblInventory>
<tblInventory ID="2">
<ProductName>Joy Buzzer</ProductName>
<RetailPrice>9.99</RetailPrice>
<Description>They will get a real shock out of this.</Description>
</tblInventory>
<tblInventory ID="3">
<ProductName>Seltzer Bottle</ProductName>
<RetailPrice>15.24</RetailPrice>
<Description>Seltzer sold separately.</Description>
</tblInventory>
<tblInventory ID="4">
<ProductName>Ant Farm</ProductName>
<RetailPrice>14.99</RetailPrice>
<Description>Watch ants where they live and breed.</Description>
</tblInventory>
<tblInventory ID="5">
<ProductName>Wind-Up Robot</ProductName>
<RetailPrice>29.99</RetailPrice>
<Description>Giant robot: attack toybox!</Description>
</tblInventory>
<tblInventory ID="6">
<ProductName>Rubber Eyeballs</ProductName>
<RetailPrice>0.99</RetailPrice>
<Description>Peek-a-boo!</Description>
</tblInventory>
<tblInventory ID="7">
<ProductName>Doggy Mess</ProductName>
<RetailPrice>1.99</RetailPrice>
<Description>Yechhh!</Description>
</tblInventory>
<tblInventory ID="8">
<ProductName>Mini-Camera</ProductName>
<RetailPrice>9.99</RetailPrice>
<Description>For future spies!</Description>
</tblInventory>
<tblInventory ID="9">
<ProductName>Glow Worms</ProductName>
<RetailPrice>1.99</RetailPrice>
<Description>Makes them easy to find</Description>
</tblInventory>
<tblInventory ID="10">
<ProductName>Insect Pops</ProductName>
<RetailPrice>0.99</RetailPrice>
<Description>Special treats</Description>
</tblInventory>
<tblInventory ID="11">
<ProductName>Alien Alarm Clock</ProductName>
<RetailPrice>45.99</RetailPrice>
<Description>Do you know what time it is out there?</Description>
</tblInventory>
<tblInventory ID="12">
<ProductName>Cinnamon Toothpicks</ProductName>
<RetailPrice>1.99</RetailPrice>
<Description>Really wakes up your mouth</Description>
</tblInventory>
</NewDataSet>
Для составления ведомости на выдачу заработной платы сотрудникам компании нужно создать код сохранения информации о сотрудниках в формате XML для каждого отдела. Для этого разработчик базы данных должен включить в форму frmPrepareXML вторую кнопку btnEmployees и вставить в код класса формы frmPrepareXML код из листинга 10.9.
Листинг 10.9. Код сохранения данных из таблиц tblEmployee и tblDepartment в XML-файлеPrivate Sub btnEmployees_Click (ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnEmployees.Click
Dim dsEmployees As New DataSet()
Dim daEmployees As New SqlDataAdapter _
("select * from tblEmployee", en)
Dim daDepartments As New SqlDataAdapter _
("select * from tblDepartment", en)
daDepartments.Fill(dsEmployees,"tblDepartment")
daEmployees.Fill(dsEmployees, "tblEmployee")
' Определение отношения между таблицами.
dsEmployees.Relations.Add("DepartmentEmployees", _
dsEmployees.Tables("tblDepartment").Columns("ID"), _
dsEmployees.Tables("tblEmployee").Columns("DepartmentID"))
' Сохранение данных в XML-файле.
dsEmployees.WriteXml("..\Employees.xml")
End Sub
В этом коде для сохранения данных из таблиц tblDepartment и tblEmployee в XML-файле используются предлагаемые по умолчанию параметры объекта DataSet. Полученный в результате XML-файл Employees.xml показан в листинге 10.10.
Листинг 10.10. XML-файл Employees. xml, полученный в результате сохранения данных из таблиц tblDepartment и tblEmployee<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<tblDepartment>
<ID>1</ID>
<DepartmentName>Administration</DepartmentName>
</tblDepartment>
<tblDepartment>
<ID>2</ID>
<DepartmentName>Engineering</DepartmentName>
</tblDepartment>
<tblDepartment>
<ID>3</ID>
<DepartmentName>Sales</DepartmentName>
</tblDepartment>
<tblDepartment>
<ID>4</ID>
<DepartmentName>Marketing</DepartmentName>
</tblDepartment>
<tblEmployee>
<ID>1</ID>
<FirstName>Carole</FirstName>
<LastName>Vermeren</LastName>
<DepartmentID>2</DepartmentID>
<Salary>222</Salary>
</tblEmployee>
<tblEmployee>
<ID>2</ID>
<FirstName>Cathy</FirstName>
<LastName>Johnson</LastName>
<DepartmentID>2</DepartmentID>
<Salary>13000</Salary>
</tblEmployee>
<tblEmployee>
<ID>3</ID>
<FirstName>Eric</FirstName>
<LastName>Haglund</LastName>
<DepartmentID>4</DepartmentID>
<Salary>12000</Salary>
</tblEmployee>
<tblEmployee>
<ID>4</ID>