tags:

views:

91

answers:

1

I'm trying to parse the xml of an rss feed (StackOverflow's funnily enough), and I want to get the ID, date, title and link from each rss entry for my rss feed reader.

Using Liquid XML Studio, I have code as follows:

XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsMgr.AddNamespace("tns", "http://www.w3.org/2005/Atom");
nsMgr.AddNamespace("thr", "http://purl.org/syndication/thread/1.0");
nsMgr.AddNamespace("creativeCommons", "http://backend.userland.com/creativeCommonsRssModule");

XmlNodeList selectedNodes = xmlDoc.SelectNodes("/tns:feed/tns:entry/", nsMgr);
foreach (XmlNode selectedNode in selectedNodes)
{
  // ...
}

When I get to the line "XMlNodeList selectedNodes...", I get this error:

Expression must evaluate to a node-set.

The exception is of type XPathException.

What am I missing? The code and expression seem fine to me. I want to get the inner value of id, date, etc.

Thanks

A: 

Your XPath is invalid. Try something like:

"//tns:feed/tns:entry"

or:

"tns:feed/tns:entry"
Jeff Yates