Before digging into this tip, I’d just like to mention that I thoroughly enjoy topics that require titles as complex as this blog’s.
I’ve just been playing with the .Net Framework’s awesome new LINQ (Language INtegrated Query) syntax and discovered a fun little problem when using LINQ To XML to parse an RSS feed. Take a look at the following code:
The core of the SELECT statement populates a Blog object with members found in the XML of the feed. This code has a bug though. The Content element will throw an exception when it tries to find the XName “content:encoded”, even though that is included in the XML from the feed.
This can be resolved by relying on the namespace for the RSS content. By changing the assignment of the Content property to look more like this:
you will be able to overcome the limitation of the XName object to access nodes with a colon in their name!
If you’ve read this blog and you are thoroughly confused regarding LINQ, .Net, XML, RSS, etc., please google these terms and read all that you can. Also, I’d be happy to write further posts going into any of these topics in more depth so please request so in comments if you are interested. I should mention that I don’t claim to be doing things *the right* way, merely a way that I have found that works. If you see something better, use it and let me know about it! Happy coding!!!