xml reading in asp table using asp.net
<p>I have the following code</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    //this part use to writing the xml file
    //string filenenter code here name = "E:\\application server\\dotnetrnd\\mahendra\\my.xml";
    string filename = Server.MapPath("\\my.xml");
    XmlDocument doc = new XmlDocument();
    XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8);
    xmlWriter.Formatting = Formatting.Indented;
    xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
    xmlWriter.WriteStartElement("StateDetail");
    xmlWriter.Close();
    doc.Load(filename);
    con.Open();
    cmd = new SqlCommand("State_Update", con);
    cmd.CommandType = CommandType.StoredProcedure;
    dr = cmd.ExecuteReader();
    try
    {
        if (dr.HasRows)
        {
            while (dr.Read())
            {
                XmlNode root = doc.DocumentElement;
                XmlElement child1 = doc.CreateElement("State");

                // Retriving State ID
                XmlAttribute ID1 = doc.CreateAttribute("id");
                ID1.Value = dr["id_State"].ToString();
                child1.Attributes.Append(ID1);              //Adding attribute in chil1

                // Retriving State Name
                XmlAttribute name1 = doc.CreateAttribute("name");
                name1.Value = dr["State_name"].ToString();
                child1.Attributes.Append(name1);

                // Retriving State Description
                XmlAttribute description = doc.CreateAttribute("description");
                description.Value = dr["State_description"].ToString();
                child1.Attributes.Append(description);

                //Adding into root element
                root.AppendChild(child1);
                //Response.Write("&lt;br&gt;&lt;br&gt;" + dr["State_name"].ToString());

                //Creating sub-element in child1
                con1.Open();
                cmd1 = new SqlCommand("XMLCity_Retrive", con1);
                cmd1.Parameters.Add("@id_State", SqlDbType.VarChar).Value = dr["id_State"].ToString();
                cmd1.CommandType = CommandType.StoredProcedure;
                dr2 = cmd1.ExecuteReader();
                if (dr2.HasRows)
                {
                    while (dr2.Read())
                    {
                        // Response.Write("&lt;br&gt;"+dr2["City_name"].ToString());
                        // Retriving City ID
                        XmlElement city = doc.CreateElement("City");
                        XmlAttribute ID2 = doc.CreateAttribute("id");
                        ID2.Value = dr2["id_City"].ToString();
                        city.Attributes.Append(ID2);  //Adding attribute in chil1

                        // Retriving City Name
                        XmlAttribute name2 = doc.CreateAttribute("name");
                        name2.Value = dr2["City_name"].ToString();
                        city.Attributes.Append(name2);

                        // Retriving City Description
                        XmlAttribute descr = doc.CreateAttribute("description");
                        descr.Value = dr2["City_description"].ToString();
                        city.Attributes.Append(descr);

                        //Adding into child1 element
                        child1.AppendChild(city);
                    }
                }
                dr2.Close();
                con1.Close();
            }
        }
        doc.Save(filename);
        dr.Close();
        con.Close();
    }
    catch (Exception ex)
    {
        Response.Write("Exception is " + ex.Message);
    }


    //this part use for reading xml
    try
    {
        DataTable dt;
        using (XmlReader reader = XmlReader.Create(filename))
        {
            string result;
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    result = "";
                    //for (int count = 1; count &lt;= reader.Depth; count++)
                    // {
                    result += "==";
                    //}
                    //result += "=&gt;" + reader.Name;
                    Response.Write(" " + reader.Value);
                    //tr2 = new TableRow();
                    //    td2 = new TableCell();       
                    //lblres.Text += result;
                    //Response.Write(result);
                    if (reader.HasAttributes)
                    {
                        //lblres.Text += "(";
                        // for (int count = 0; count &lt; reader.AttributeCount; count++)
                        //{
                        //reader.MoveToAttribute(count);
                        // reader.MoveToFirstAttribute();
                        // reader.MoveToNextAttribute();
                        //lblres.Text += " " + reader.GetAttribute(0).ToString().Trim();
                        //lblres.Text += " " + reader.GetAttribute(1);
                        // lblres.Text += " " + reader.GetAttribute(2);
                        Table tb = new Table();
                        TableRow tr = null;
                        TableCell td = null;
                        tr = new TableRow();
                        td = new TableCell();
                        td.Text = reader.GetAttribute(0).ToString();
                        td.BorderStyle = BorderStyle.Ridge;
                        tr.Cells.Add(td);
                        t1.Rows.Add(tr);

                        td = new TableCell();
                        td.Text = reader.GetAttribute(1).ToString();
                        td.BorderStyle = BorderStyle.Ridge;
                        tr.Cells.Add(td);

                        td = new TableCell();
                        td.Text = reader.GetAttribute(2).ToString();
                        td.BorderStyle = BorderStyle.Ridge;
                        tr.Cells.Add(td);
                        t1.Rows.Add(tr);

                        // Response.Write(" " + reader.GetAttribute(0).ToString().Trim() + "&lt;br&gt;");
                        // Response.Write(" " + reader.GetAttribute(1).ToString().Trim());
                        // Response.Write(" " + reader.GetAttribute(2).ToString().Trim()  );
                        //Response.Write("" + reader.GetAttribute(0));
                        // }
                        //  lblres.Text = ")";
                        reader.MoveToElement();
                    }
                    //lblres.Text += "&lt;br&gt;";
                    Response.Write("&lt;br&gt;");
                }
            }
        }
        DataSet XMLDataset;
        string filepath = Server.MapPath("my.xml");
        XMLDataset = new DataSet();
        XMLDataset.ReadXml(filepath);
        gridxml.DataSource = XMLDataset.Tables["State"];
        XMLDataset.Clone();
        gridxml.DataBind();
    }
    catch (Exception exp)
    {
        Response.Write("An exception occured : " + exp.Message);
    }
}
</code></pre>

<p>I have done this in normal HTML table but I want this data in Asp table how can I do this?</p>
