This project has moved. For the latest updates, please go here.

Unordered channel serialization problem solved

Nov 23, 2008 at 11:21 AM
I thought I read another post that someone else was having the same problem, but I can't find it now. I was having problems with huge aggregated feeds I was creating with the toolkit (from OPML files) due to the fact that the RSS channel element in the XML output wasn't being ordered correctly. I'm having some issues that I *think* are caused by some RSS readers expecting the channel title, link, description, etc. to be ABOVE the channel items. By default the serializer puts the title and link BELOW all the items. To change the order of the channel items, edit RssChannel.cs and add an Order attribute for each element, and make sure the Items is the last (highest) order item. For example, for the Title element I specified:

[XmlElement("title", Order = 1)]

followed by the link (Order = 2) and description elements (Order = 3)

Then ordered all the rest of the elements and made sure that Items was Order = 20.

That fixed the ordering problems!

Dec 21, 2008 at 10:54 AM
Edited Dec 21, 2008 at 10:54 AM
I found a nasty gotcha with this solution. It's not such a great idea. If you use the Order attribute, it works great when creating a feed, but when reading a feed, if the elements are not in that order, they won't all be read! This is obviously bad. So... back to the drawing board. It appears that all the elements are written out in alphabetical order. I'm not sure why that is or how I can influence it, I need to poke around. I suspect that Google reader isn't happy about the <title> element being the last thing in an <item> element, which is what's happening with the default element ordering. I'm not sure, it's being very fussy about displaying titles, even though the feed validates.