Twitter / kaizenx

Thursday, November 22, 2007

Good old fashioned programming

After almost 4 days of messing around with RSS and XSL, the solution to my problem was actually just some decent programming on C#.

I wanted to select only the first two posts of a blog from its RSS feed. So I loaded the RSS feed into a dataset in C#, then created a pagedatasource object and pumped in the defaultview of the dataset.

I then turned on paging and set pagesize to 2. The datalist that I was binding to the new pagedatasource didn't like it, throwing IXPathNavigable errors.

After a day of tinkering around with XPath and producing no results at all, I switched strategy and decided to just go play around with XSL and not using a pagedatasource at all since not playing around with pagedatasource seemed to work, I could at least bind the dataset to my datalist.

Yesterday and most of today, I messed around with XSL trying to do a for-loop from 1st row to 2nd row to show only the first two entries of the rss feed.

Either my understanding of XSL is flawed or the feed that was being sent was weird, but my endeavours at XSL failed to do anything useful.

Around 3 hours ago, I decided to approach it from a very fundamental level.

I could load it into a dataset and display the dataset.

What if I looped through the dataset and take the first two rows of the blog?

After 10 minutes of coding, I managed to extract anything I wanted out of the first 2 rows. I then made a datatable, a datarow and another dataset.

Binded the results of the first two rows of the original dataset to the datarows, and added the datatable to the new dataset and used that dataset instead as my datasource :P

Kinda of a roundabout way of doing it but I guess if it works it works lar.

No comments: