tailieunhanh - Work with Datasets and XML

Làm việc với datasets và XML Đôi khi, tôi phải kéo các tài liệu XML thành datasets và ngược lại. Làm thế nào để thực hiện điều này bằng cách sử dụng. NET? Kỹ thuật. NET đã phát triển một số cách để sử dụng datasets và XML cùng | Work with Datasets and XML Sometimes I have to pull XML documents into datasets and vice versa. How do I accomplish this using .NET Technique .NET has developed a number of ways to utilize datasets and XML together. The simplest use is pushing data between the two. To do this you have the two methods belonging to the DataSet object ReadXML and WriteXML. For both of these methods you need to provide a filename to read or write the XML document to. To demonstrate how to take advantage of these methods I created a form that looks similar to the other How-Tos showing how to write XML documents. However for this example I also added another button and data grid that will show the data after reading from the XML document. Steps Open and run the Visual Basic .NET-Chapter 12 solution. From the main Web page click on the hyperlink with the caption How-To Working with Datasets and XML. As with How-To when the page loads you can enter a few names. Enter the last and first names and then click the button labeled Add to DataTable. When you have added a few names click the button labeled Create XML File. Using Explorer open the file created in C called . If you click Read XML File you will see the same data because it was read from see Figure . 1. Create a Web Form. Then place the Labels TextBoxes Buttons and DataGrid objects as seen in Figure on the form with the properties set as in Table . Table . Label TextBox and Button Control Property Settings Object Property Setting Label Text Last Name TextBox ID txtLastName Label Text First Name TextBox ID txtFirstName Button ID btnAdd Text Add to DataTable Button ID btnCreateXMLF ile Text Create XML File DataGrid ID dgDataTo Write Button ID btnReadFile DataGrid ID dgRe sultsF romXML HyperLink ID hplReturnT oMain NavigateURL 2. Add the following line to the code module of the form. Then place it under the line that reads Web Form Designer Generated Code. 3. Dim mdtData As