By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

Namespaces & Atom feeds

P: n/a
I'm new to XML namespaces, and I seem to be missing something obvious
in this code snippet, which is trying to retrieve the feed/entry nodes
from an XPathNavigator document:

XmlNamespaceManager mgr = new
XmlNamespaceManager(xpNav.NameTable);
mgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");

XPathExpression itemsExpr = xpNav.Compile("/atom:feed/
atom:entry/");
itemsExpr.SetContext(mgr);

XPathNodeIterator items = xpNav.Select(itemsExpr);

The error comes back...

"The expression passed to this method should result in a NodeSet." --
and, indeed, the XPathNodeIterator doesn't result in any entries.

I'm using .Net 1.1. I believe this might affect the final code.

Thanks for any pointers.

--Brent
Jul 1 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* Brent wrote in microsoft.public.dotnet.xml:
>I'm new to XML namespaces, and I seem to be missing something obvious
in this code snippet, which is trying to retrieve the feed/entry nodes
from an XPathNavigator document:

XmlNamespaceManager mgr = new
XmlNamespaceManager(xpNav.NameTable);
mgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");

XPathExpression itemsExpr = xpNav.Compile("/atom:feed/
atom:entry/");
Remove the final slash.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jul 1 '08 #2

P: n/a
Thank you! This fix resolved my issue completely.

--Brent

On Jul 1, 12:35*am, Bjoern Hoehrmann <bjo...@hoehrmann.dewrote:
* Brent wrote in microsoft.public.dotnet.xml:
I'm new to XML namespaces, and I seem to be missing something obvious
in this code snippet, which is trying to retrieve the feed/entry nodes
from an XPathNavigator document:
* * * *XmlNamespaceManager mgr = new
XmlNamespaceManager(xpNav.NameTable);
* * * *mgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
* * * *XPathExpression itemsExpr = xpNav.Compile("/atom:feed/
atom:entry/");

Remove the final slash.
--
Björn Höhrmann · mailto:bjo...@hoehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
Jul 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.