Display xml data from XML In GridView

Posted by Thiru under ASP.NET on 11/3/2011 | Points: 10 | Views : 7398 | Status : [Member] | Replies : 2
Hi Frineds,
When i try to get XML data from XML file using GridView - Its showing only the top heading only.

I like to get all the data from xml to gridview.
How to do this?

(i have attached the xml file herewith)

Expecting your valuable reply
Regards,
Thiru




Responses

Posted by: Klbaiju on: 11/3/2011 [Member] Starter | Points: 25

Up
0
Down
Hi friend

try this example
suppose this is an xml file.
save the xml file as people.xml
<Peoples>

<people>
<name>arjun</name>
<age>28</age>
<salary>5000</salary>
</people>
<people>
<name>kiran</name>
<age>25</age>
<salary>8000</salary>
</people>

</Peoples>

write the code in page load

DataSet ds=new DataSet();
ds.ReadXml(Server.MapPath("people.xml"));
Grid1.DataSource=ds;
Grid1.DataBind();

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 11/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi thanks for your reply.
you have mention it correctly - but i like to use SqlDataSource for event.xml file and use the same in gridview
for the same xml file which attached in my first post here. (event.xml)

note: i should not do any structure alteration in that xml

Its getting listed only the date but not the content inside each date.

Expecting your valuable reply.


Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response