Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Namespaces & Atom feeds

Question posted by: Brent (Guest) on July 1st, 2008 07:25 AM
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
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Bjoern Hoehrmann's Avatar
Bjoern Hoehrmann
Guest
n/a Posts
July 1st, 2008
07:45 AM
#2

Re: Namespaces & Atom feeds
* Brent wrote in microsoft.public.dotnet.xml:
Quote:
Originally Posted by
>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:bjoern@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/

Brent's Avatar
Brent
Guest
n/a Posts
July 2nd, 2008
05:45 AM
#3

Re: Namespaces & Atom feeds
Thank you! This fix resolved my issue completely.

--Brent

On Jul 1, 12:35*am, Bjoern Hoehrmann <bjo...@hoehrmann.dewrote:
Quote:
Originally Posted by
* Brent wrote in microsoft.public.dotnet.xml:
>
Quote:
Originally Posted by
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:

>
Quote:
Originally Posted by
* * * *XmlNamespaceManager mgr = new
XmlNamespaceManager(xpNav.NameTable);
* * * *mgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");

>
Quote:
Originally Posted by
* * * *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/



 
Not the answer you were looking for? Post your question . . .
182,333 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors