Reading and Writing XML Files with the DataSet
The Xml server control is not your only option for rendering XML data in a browser. You also can read XML documents into a DataSet and bind the DataSet to any available server control, such as the DataGrid. Using the System.IO.StreamReader class, you can stream in XML data and use the DataSet.ReadXml() method to dynamically create a DataTable based on the XML data. Listing 12.12 shows how to do this in a Web Form.
Listing 12.12. Reading XML Data into a DataSet and Binding It to a DataGrid
[VB] 01: <%@ Import Namespace="System.Data" %> 02: <%@ Import Namespace="System.Xml" %> 03: <script language="VB" runat=server> 04: Protected Sub Page_Load(Sender As Object, E As EventArgs) 05: Dim myDataSet As ... |
Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.