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:

Comments

5/21/2008 9:41:08 AM

Gürkan Yeniçeri

Using xmldatasource; ordering can be done with a style sheet (xsl) suitable for your xml data.

Gürkan Yeniçeri au

5/21/2008 10:50:22 AM

volkanuzun

Himm i really didnt know that, can u sort according to datetime or sorting on strings ?

volkanuzun us

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



About the author

Volkan Uzun




E-mail me Send mail

Twitter

Calendar

<<  December 2008  >>
MoTuWeThFrSaSu
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

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