Click here to Skip to main content
16,017,502 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to retrieve data from xml file into the form.
Posted

 
Share this answer
 
Hi Bhargavi you can use following code for retrieving data from xml and displaying it on GridView:
At first add System.xml namespace.

C#
XmlTextReader xtr = new XmlTextReader(Server.MapPath("myXml.xml"));
DataSet ds = new DataSet();
ds.ReadXml(xtr);
xtr.Close();
if(ds.Tables.Count != 0)
{
  gridview.DataSource = ds;
  gridview.DataBind();
  //gridview is ID of your GridView Control.
 }


All the best.
 
Share this answer
 
Comments
Bhargavi Rangam 17-Aug-12 23:59pm    
If i want to search for some key in xml and retrieve corresponding value , then how to access fields in xml.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900