tailieunhanh - Assembly Language: Step-by-Step - part 9

Đây là giáo trình lập trình C# bằng tiếng Anh dành cho giáo viên, sinh viên chuyên ngành công nghệ thông tin tham khảo. | 368 Chapter 9 Reading an XML Document into the DataSet Reading XML data into a DataSet can be done by simply using the ReadXml method of the DataSet. This method has several overloads but one of the overloads allows a filename to be passed into the method. The filename must be a physical path which means that when the XML document is on the Web server the method can be used with a relative virtual address to obtain the physical path. The following code shows an example of reading an XML file into the DataSet and then displaying the data in a DataGrid Private Sub Button13_Click _ ByVal sender As _ ByVal e As _ Handles Dim ds As New DataSet MyCompany C Employee DataBind End Sub The browser output is shown in Figure . This code reads the file into the DataSet. The DataSet parses the repeating rows into tables. The end result is that two tables are created the Employee table and the Address table. The DataSet does well at identifying the XML data but all of the data types are strings and many of the data types such as dates and numbers produce the desired results. This can be corrected by supplying an XML schema. An XSL schema can be supplied as a separate file or it can be embedded into the XML file. For the file an XML schema might look like the following XML version standalone yes xs schema id EmployeeList xmlns xmlns xs http 2001 XMLSchema xmlns msdata urn schemas-microsoft-com XML-msdata xs element name EmployeeList msdata IsDataSet true xs complexType xs choice maxOccurs unbounded xs element name Employee id EmpID xs complexType xs sequence xs element name HireDate type xs dateTime minOccurs 0 msdata Ordinal 0 xs element name Address minOccurs 0 maxOccurs unbounded Working with XML Data 369 xs complexType xs sequence xs element name Street1 type xs string minOccurs 0 xs element name Street2 .

TỪ KHÓA LIÊN QUAN