XML, Linq, GridView, Label

by volkanuzun 5/18/2008 2:59:00 AM

I had a very small project, where there would be page that lists events, another page that adds events. I didnt want to have a database for this simple pages, so i decided to go on with xml file. My xml file structure is basically like below: 


Now i need a pagethat will list all the events (hopefully ordering them according to When attribute which is a datetime. so i created a page put a label on the page, and open the code behind file.

What i want to do is, open the xml file, order them, and dump the data into the label, so i decided to use linq, as i am learning this new technique. Below is the simple code for this, linq made it so easy for me to parse the xml; unbelievable:

 


BTW you could do the exact same thing with xmldatasource and xpath, however; i am not sure with ordering :), ordering wont be that easy i guess with xmldatasource, here is the page that does the above listing with xmldatasource and gridview and xpath:

 

Tags:

About the author

Volkan Uzun




E-mail me Send mail

Twitter

Calendar

<<  May 2008  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Flickr Badge

www.flickr.com
This is a Flickr badge showing public photos from volkanuzun. Make your own badge here.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in