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
0
7/1/2008 7:15:54 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
714 Views

Similar Articles

[PageSpeed] 22

* 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/ 
0
bjoern1 (135)
7/1/2008 7:35:04 AM
Thank you! This fix resolved my issue completely.

--Brent

On Jul 1, 12:35=A0am, Bjoern Hoehrmann <bjo...@hoehrmann.de> 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:
>
> > =A0 =A0 =A0 =A0XmlNamespaceManager mgr =3D new
> >XmlNamespaceManager(xpNav.NameTable);
> > =A0 =A0 =A0 =A0mgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
>
> > =A0 =A0 =A0 =A0XPathExpression itemsExpr =3D xpNav.Compile("/atom:feed/
> >atom:entry/");
>
> Remove the final slash.
> --
> Bj=F6rn H=F6hrmann =B7 mailto:bjo...@hoehrmann.de =B7http://bjoern.hoehrma=
nn.de
> Weinh. Str. 22 =B7 Telefon: +49(0)621/4309674 =B7http://www.bjoernsworld.d=
e
> 68309 Mannheim =B7 PGP Pub. KeyID: 0xA4357E78 =B7http://www.websitedev.de/=


0
7/2/2008 5:40:07 AM
Reply:

Similar Artilces:

Why is XMLSchema namespace so different than my custom namespace?
Below is a snippet that I'm sure is quite familiar to most ... <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" Here, I've given the XMLSchema namespace the prefix 'xsd', and with that, I can reference datatypes within the XMLSchema namespace ... i.e., xsd:string. That's great, but why can't I use that same notation, to reference dataypes in a homegrown schema ... WITHOUT doing an <import> or <include>? Is the XMLSchema (and the XMLSchema-instance) sort of "built-in" to XML tools, such that they don't need to go find th...

Namespaces
Is there any documentations that will explain the Namespaces better or any help file? -- Matthew Heinrich Casino Queen Inc. Development Team ...

How can I create custom page size for tractor-feed forms? (2007)
I have created a report to print out information for book acquisition at our library but cannot change the page size to a custom size for the tractor-feed forms. I am using Access 2007. Any ideas? Jhall@myglnc.com "RunningRonnie" <RunningRonnie@discussions.microsoft.com> wrote in message news:553F4C4B-AF9E-4911-8385-2D6D9DA8B683@microsoft.com... >I have created a report to print out information for book acquisition at >our > library but cannot change the page size to a custom size for the > tractor-feed > forms. I am using Access 2007. Any ideas? ...

XmlSerializer and blank namespace
In 1.1, I could do this: XmlSerializer xs = new XmlSerializer(typeof(Doodad)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.add("", ""); xs.Serialize(writer, doodad, ns); and it produced: <doodad> .... </doodad> In 2.0, the same code produces: <doodad xmlns=""> .... </doodad> Any idea why and how to get rid of the blank namespace? ...

How can I feed data to other sheets?
I would like to have a workbook with data of different persons and then feed this information to another workbook for each individual. Is this possible? Hi Sil Do you mean this http://www.rondebruin.nl/copy5.htm See http://www.rondebruin.nl/copy5.htm#workbook -- Regards Ron de Bruin http://www.rondebruin.nl "Sil" <Sil@discussions.microsoft.com> wrote in message news:49D90B6D-8943-47CC-9C78-6C10376029CF@microsoft.com... >I would like to have a workbook with data of different persons and then feed > this information to another workbook for each individual. > &g...

Xpath with namespaces
Hello Everyone, I am having an issue with xml and namespaces, at least I think it is namespaces. When I use namespaces, I cannot use SelectSingleNode / SelectNodes as they always return 0/Nothing respectively. Anyone have any thoughts? Thanks in advance VB.Net 2005 WinXP Sp2 Test code: Dim objXML As System.Xml.XmlDocument 'Test XML 1 ==> Always returns 0 objXML = New System.Xml.XmlDocument objXML.Load(Application.StartupPath & "\xmlfile1.xml") MsgBox(objXML.SelectNodes("top/middle").Count) 'Test XML 2 ==> Always re...

XML namespaces and XSD.exe
Oh boy i'm getting tangled in knots here. I have a schema which contains <xs:schema targetNamespace="http://Southend.Schemas.PAS/PASPatientDemographics.xsd" id="PASPatientDetails" xmlns:sh="http://Southend.Schemas.PAS/PASPatientDemographics.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> now i used the xsd.exe and it now generates elements when I serilaize the class I get <RequestingPatient_ID xmlns="">D1234567890</RequestingPatient_ID> So each emlement contains xmlns=&qu...

Can I create an RSS feed with Publisher 2003 input?
I have a church newsletter in MS Publisher we want to publish on the Internet. Is there a way to directly output RSS content from Publisher. A google search doesn't turn up any answers. Thanks! On Mon, 30 Jan 2006 16:36:15 +0000, Richard wrote (in article <101C96ED-DCCF-4066-90AE-9E241D2C2971@microsoft.com>): > I have a church newsletter in MS Publisher we want to publish on the > Internet. Is there a way to directly output RSS content from Publisher. A > google search doesn't turn up any answers. > Thanks! That's because the answer is "no". ...

Redundant namespace descriptors
Using this target schema: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=24480 I generate this xml: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=24481 using the VS editor. For the boolean attribute 'Selected' in the Answer tags a complete namespace is redefined xmlns:d3p1="http://tempuri.org/QuizData.xsd." This seems pretty redundant to me and would lead to some awful code bloat in a large file. Is there any way to fix this so that I not generating a new namespace definition in every tag? ...

Conditional namespace
Hi Everyone, I want to include the namespace "using Windows7.DesktopIntegration" in my C# project only if the current OS is Windows 7, for other OS like Xp,2000,vista I need to ignore the same. Any idea for achieving this will helpful for me. -- Thanks and Regards, Shankar B. Shankar wrote: > Hi Everyone, > > I want to include the namespace "using Windows7.DesktopIntegration" in my C# > project only if the current OS is Windows 7, for other OS like Xp,2000,vista > I need to ignore the same. > I'm puzzled. AFAIK the only r...

Feeding Worksheet Data Into a Query
If I have 4 values that reside in a worksheet in cells F1:F4, how do I take these values and specify these as criteria in my where clause: WHERE ID IN (F1:F4) I need a comma separated list of IDs so that the T-SQL statement can be executed correctly, WHERE ID IN (F1,F2,F3,F4) There's always more than 1 way to skin a cat ... One way to solve your problem would be to dim 5 variables. Example: (I am going to assume your values are string values.) Dim strA As String, strB As String, strC As String, D As String Dim strWhereSQL As String strA = Range("F1").Value strB = Range(&...

Testing for non-existing namespace attribute?
Hello! I'm using msxml3 in the C++ environment, VC 7.1.3088. How do I know if the namespace attribute doesn't exist? I want to put it in a std::string, and I try to do that like this: string CXmlNodeWrapper::GetNamespaceURI() const { if( IsValid() ) { _bstr_t str = m_xmlnode->GetnamespaceURI(); return static_cast<char*>(str); // <- point of exception } return ""; } m_xmlnode is a MSXML2::IXMLDOMNodePtr; This works fine as long as there is a namespace attribute, but if the root node doesn't have a namespace attribute thi...

SelectSingleNode and Namespace
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C54429.49A1B710 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I use a XML-Doc with a Namespace like the following example: <HomedResources = xmlns=3Dhttp://schemas.microsoft.com/RtcServer/2002/11/dbimpexp = Version=3D"3"> <HomedResource UserAtHost=3D"PBoul@team.de" Enabled=3D"1" = VersionPermission=3D"10" =20 VersionContact=3D"25" DisplayName=3D"Boullay, Peter" = Email=3...

Serializing Class with Unqualified Root Element and Default Namespace attribute
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c. The problem I'm running into is that the root element needs to be unqualified, and the default namespace needs to be included on it as an attribute. The schema I'm using is this: <xs:schema xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:xs="http://www...

XPathNavigation and Namespaces.
I have the following code that is attempting to read nodes from an xml file... XmlDocument xpdStatus = new XmlDocument(); xpdStatus.Load("status.xml"); XPathNavigator xpnStatus = xpdStatus.CreateNavigator(); XPathNodeIterator xpniStatus = xpnStatus.Select("descendant::Status"); while (xpniStatus.MoveNext()) { Console.WriteLine("Book title: {0}", xpniStatus.Current.Value); XmlNode node = ((xpniStatus.Current) as IHasXmlNode).GetNode(); Console.WriteLine("Status: {0}", node.Value); } The code works fine until I attempt to add namespaces, with prefixes...

Xpath Search with Namespaces
I've run into a problem trying to search an XML document with a namespace. Sample extract is below: <Vendors xmlns="http://tempuri.org/Vendor.xsd"> <Vendor> <VendorID>002010</VendorID> <PropricerId>002010S</PropricerId> <VendorName>AEROTEK, INC.</VendorName> </Vendor> <Vendor> <VendorID>002012</VendorID> <PropricerId>002012S</PropricerId> <VendorName>ARONSON &amp; COMPANY</VendorName> </Vendor> <Vendor> <VendorID>002018</VendorID> <P...

Namespaces ?
What see sample that show xs:element where the xs namespace = http://www.w3.org/2001/XMLSchema However, I see another example with xsi: where xsi = http://www.w3.org/2001/XMLSchema-instance What's the difference here? Are there right and wrong namespaces? Is there a global list of the ones to use? Does the namespace even need to point at http://www.w3.org.....? Or is this just the accepted way? Very appreciative, Mike Morse They are different namespaces that refer to different things. for more on XML Namespaces, See http://www.w3.org/TR/REC-xml-names/ http://msdn.microsoft.com/...

Adding Namespaces to Outlook Possible?
I'm a developer that have on a number of occasions written namespace extentions for the windows shell (Windows Explorer). I have a need to do something similar with Outlook. I would like to be able to write a namespace extention to Outlook allowing me to add a hierarchy to the tree or folder view and handle the listview myself. Just like a namespace extention in windows explorer. I have done some internet searches and come up empty so my guess is that this is not supported or documented. However if it is possible and the interfaces are named and documented then this would be a real bo...

Problem with XML Namespace
Hello, As a VB6 programmer, I'm quite a newbee in .NET. I'm working with Visual Studio .NET 2005 Beta2 and try write a class that reads an online xml document. Let's say, something you would do with XmlHttp in VB6. My problem is, that my GUI does not recornize the System.xml namespace. I get this error: "namespace or type specified in the imports 'System.xml' cannot be found" Why do I get this error? Thanks, Ramon. Ramon wrote: > As a VB6 programmer, I'm quite a newbee in .NET. > > I'm working with Visual Studio .NET 2005 Beta2 and try...

Using XPath with namespaces
Hello, I have been trying to get data from an xml file with a namespace. I have followed the example in the MSDN, but I get no data in t he XPathNodeIterator, but the file has the data I am trying to extract. ... XPathNavigator navigator = xmlDoc.CreateNavigator(); // xpathQuery = "/ProductInformation/ProductNumber" XPathExpression expr = navigator.Compile( xpathQuery ); expr = navigator.Compile( xpathQuery ); XmlNamespaceManager nsmgr = new XmlNamespaceManager( navigator.NameTable ); nsmgr.AddNamespace( "myNS", "http://www.orange.com/schemas/imaging/cyanblue/dev/1...

XmlNamespaceManager, default namespaces, nested qualified namespace, xpath problem.
Hi, I can't for the life of me get this to work properly. I've searched for examples, but none of the examples quite match my environment. Here is my XML (please treat this as immutable -- no solutions involving altering the XML are good for me): ---- config.xml ---- <Configuration xmlns="urn:server:schemas:configuration" xmlns:f="urn:server:schemas:faq"> <version version="0.0.0001"> <f:faq> <f:section>Default</f:section> <f:item> <f:q>What is the mean...

domain namespace
I have an internal domain (Example: joe.ad) and external domain (joe.com) but I don't want my internal domain to be publicly accessible but able to route mail in/out? Please provide more detail what you're trying to accomplish. -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "souldog" <souldog@discussions.microsoft.com> wrote in message news:0F30A075-9096-4190-9325-47AA7BE9EE16@microsoft.com... >I have an internal domain (Example: joe.ad) and external domain (joe.com) >but > I don't want my internal domain t...

namespace of AfxLoadLibrary
Hi, I did not find in which namespace is define AfxLoadLibrary(). I'm migrating my app under .NET and as i did not find something useful in .NET (event if DllimportAttribute exists), i would like to mix MFC and .NET in a class. thanks a lot, Alain "--== Alain ==--" <nospam@noemail.com> wrote in message news:uoWGEF67GHA.3340@TK2MSFTNGP04.phx.gbl... > Hi, > > I did not find in which namespace is define AfxLoadLibrary(). This is a MFC method and this does not have a namespace as .Net does or perhpas its what you may call a global namespace. You should be able ...

XPath and namespaces
Hi; First off, I think I still do not understand exactly how we are supposed to handle namespaces when doing xpath queries under .NET so I may have some bad assumptions here. As I understand it, we need to set the namespaces on an XmlDocument - the ..NET libraries do not read it from the xmlns:... attributes in the xml. In our case we have to handle xml our customers will pass to our library so we do not know up front what namespaces will be in there or how they are set up. So we do the following: private void SetNamespace(XPathNavigator nav) { XPathNodeIterator list = nav.Select...

XPath with namespace
Hello all, I am working on an Add-in to the .NET framework using C#. I wanted to search the XML document using XPath but failed. The XML is like this: <unit xmlns="http://www.some.info/srcML" xmlns:cpp="http://www.some.info/srcML/cpp"> <aaa>something</aaa> </unit> The code I am using is as follows: XPathNavigator nav; XPathDocument docNav; XPathNodeIterator NodeIter; string fname="sth.xml"; docNav = new XPathDocument(@fname); nav = docNav.CreateNavigator(); nav.Evaluate(input); NodeIter = nav.Select(input); It works fine if there is n...