Converting XML to DataSet and Vice versa : DataSet « ADO.net Database « ASP.Net






Converting XML to DataSet and Vice versa

<%@ Page Language="c#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<html>
  <title>Converting XML to DataSet and Vice versa. </title>
  <head>
    <script language="c#" runat="server">
       void Page_Load(Object sender,EventArgs e) {
      try
      {
        DataSet Ds = new DataSet();
        Ds.ReadXml(Server.MapPath("Data.XML"));

        Ds.AcceptChanges();
        Ds.Tables[0].Rows[0]["LastModified"] = DateTime.Now.ToString();

        DataSet dsChanges = new DataSet();
        dsChanges = Ds.GetChanges();
        dsChanges.WriteXml(Server.MapPath("") + "\\DataWrite.xml");
      }
      catch (Exception Ex)
      {
        LblValue.Text = Ex.Message;
      }
       }
    </script>
  </head>
  <body>
    <form id="frm" runat="server">
      <asp:Label id="LblValue" runat="server" />
      <hr>
      <a href="Data.xml">Data.xml</a> | <a href="DataWrite.xml">DataWrite.xml</a>
    </form>
  </body>

 








Related examples in the same category

1.Loop through data in Sql Server by DataSet
2.Loop through DataSet
3.Get query result from DataSet
4.Load Table from DataSet
5.Build a DataSet
6.Create DataSet pragmatically
7.Build a DataSet with relationship
8.Output the content of a DataSet as XML
9.Finding a Particular Row in a DataSet
10.Converting XML to DataSet and Vice versa (VB)
11.Programmatically creating a DataSet object
12.DataSet Serialization and Deserialization using Binary Format