so I'm having some trouble with my XPath not selecting any nodes from an XML tree. Here's my code so far:
var reader = new XmlDocument();
reader.Load(@"http://www.fieldgulls.com/rss/current");
XmlNodeList list = reader.SelectNodes("./entry");
I've also tried XPath values of */entry, //entry, and others. I can't seem to get anything to work though. What am I doing wrong?
The problem is that the elements
<Entry>
are actually in the default namespace of the root node, which is"http://www.fieldgulls.com/rss/current"
:Thus you need to select nodes using the appropriate namespace and the appropriate
SelectNodes()
override:In cases like this, I find it helpful to use the following debugging utility, based on the newer LINQ to XML class library, to make the namespace of each node apparent:
Then, when debugging, you would do:
Which produces an output that starts with:
Sample fiddle.
Try to use SyndicationFeed class. It makes easy to work with RSS.