Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 1 Jul 2008 00:15:54 -0700 (PDT),    group: microsoft.public.dotnet.xml        back       


Namespaces & Atom feeds   
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
date: Tue, 1 Jul 2008 00:15:54 -0700 (PDT)   author:   Brent

Re: Namespaces & Atom feeds   
* 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: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/
date: Tue, 01 Jul 2008 09:35:04 +0200   author:   Bjoern Hoehrmann

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

--Brent

On Jul 1, 12:35 am, Bjoern Hoehrmann  wrote:
> * 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: (0)621/4309674 ·http://www.bjoernsworld.de
> 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
date: Tue, 1 Jul 2008 22:40:07 -0700 (PDT)   author:   Brent

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us