Two problems:
1) you are not loading anything into the document, you fill the
reader, but don't load the xmlDoc object
2) rss is your default namespace, you need to include it in the XPath query
XmlNodeList nodes = xmlDoc.SelectNodes("/rdf:RDF/rss:item", nsmRequest);
On 6/24/05, Helge Thomas Hellerud <[EMAIL PROTECTED]> wrote:
> Here is my code when I have tried to add the RDF namespace:
>
>
>
> XmlTextReader reader = new
> XmlTextReader("http://localhost/myFeed.xml");
>
> XmlDocument xmlDoc = new XmlDocument();
>
> XmlNamespaceManager nsmRequest = new
> XmlNamespaceManager(xmlDoc.NameTable);
>
> nsmRequest.AddNamespace("rdf",
> "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
>
> nsmRequest.AddNamespace("rss", "http://purl.org/rss/1.0/");
>
> XmlNodeList nodes = xmlDoc.SelectNodes("/rdf:RDF/item", nsmRequest);
>
> Console.WriteLine(nodes.Count.ToString());
>
>
>
> Still returning 0 nodes. why?
>
>
>
> Helge
>
>
>
>
>
>
>
> _____
>
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Helge Thomas
> Hellerud
> Sent: 24. juni 2005 17:50
> To: [email protected]
> Subject: [AspNetAnyQuestionIsOk] Parsing a RSS feed with RSS namespace
>
>
>
> Hello,
>
> How do I parse a RSS feed with elements like <foo:bar ...> (like "<rdf:RDF
> ...>")?
> How should the XPath query be?
>
> The feed:
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#
> <http://www.w3.org/1999/02/22-rdf-syntax-ns> "
> xmlns="http://purl.org/rss/1.0/"
> xmlns:dc="http://purl.org/dc/elements/1.1/"
> xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
> xmlns:admin="http://webns.net/mvcb/"
> xmlns:syn="http://purl.org/rss/1.0/modules/syndication/">
>
> <item rdf:about="http://www.myUrl.com/">
> <title>myTitle</title>
> <link>http://www.someUrl.com/</link>
> <description>myDescription</description>
> <dc:date>myDate</dc:date>
> </item>
> </rdf:RDF>
>
> Here is my code. When myQuery = "/", I get all the content of the file. When
> I try to select an item, I get 0 nodes returned. I think the problem is the
> RDF namespace, but how do I fix it?
>
> XPathDocument doc = new XPathDocument("http://localhost/myFeed.xml");
> XPathNavigator nav = doc.CreateNavigator();
> XPathNodeIterator items = nav.Select(myQuery);
>
> while (items.MoveNext())
> {
> Console.WriteLine(items.Current.Value.ToString());
> }
>
> Thanks in advance.
>
> Helge
>
>
>
>
> _____
>
> Yahoo! Groups Links
>
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
> e>
>
> * Your use of Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/> Terms of Service.
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/