Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:07:28+00:00 2026-05-29T11:07:28+00:00

What am I doing wrong with this XPath query? Within the feed tag, there

  • 0

What am I doing wrong with this XPath query? Within the feed tag, there are multiple entry tags. The XML is valid, and so is the generated XPath query, I have tested both together with a tool called XPath Visualizer.

THe call to iterator.MoveNext() returns false, and after the operation the iterator is still on the root node. Am I missing something obvious here?

var stringReader = new StringReader(importData.Trim());

        var xpathDoc = new XPathDocument(stringReader);

        XPathNavigator xPathNav = xpathDoc.CreateNavigator();

        string xPathString = "//" + masterNode; // Evaluates to '//entry'

        XPathExpression xPathExpr = xPathNav.Compile(xPathString);

        XPathNodeIterator iterator = xPathNav.Select(xPathExpr);

        while (iterator.MoveNext())
        {
           ....

Example XML

<?xml version="1.0" encoding="UTF-8"?>
            <feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0">
                <title>Test</title>
                <link rel="self" href="http://store.Test.com"/>
                <updated>2012-02-07T11:15:04Z</updated>
                <author>
                    <name>Test</name>
                </author>
                <id>tag:000000</id>
    <entry>
        <title><![CDATA[Example 7500cl]]></title>
        <link><![CDATA[http://store.test.com/example-75cl/]]></link>
        <description><![CDATA[example descr........]]></description>
    </entry>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:07:28+00:00Added an answer on May 29, 2026 at 11:07 am

    The problem is with namespaces – there aren’t any entry elements without a namespace – the element you can see has the “http://www.w3.org/2005/Atom” namespace inherited from the root.

    Personally I’d use LINQ to XML for this instead, but if you must use XPath, you’ll need to use a namespace manager to find elements with a particular namespace. A search for “xpath namespace .net” within Stack Overflow will give you lots of hits with options.

    The LINQ to XML code would look like this:

    XDocument doc = XDocument.Parse(importData.Trim());
    XNamespace ns = "http://www.w3.org/2005/Atom";
    var entries = doc.Descendants(ns + "entry");
    foreach (var entry in entries)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What am I doing wrong with this query? (Friday afternoon brain freeze...) In WordPress,
What am I doing wrong with this: $sql = SELECT * FROM content WHERE
What am I doing wrong in this HTML code: <html> <head> </head> <body> <div
Can anyone please point out what im doing wrong with this Stored Procedure please.
Hi can someone tell me what i'm doing wrong in this jquery statement. I
Am I doing something wrong is this a known issue with the ASP.NET MVC
What am I doing wrong to get this error? replacements = {} replacements[**] =
I'm mot sure if I'm doing this wrong or not I don't know if
I hope this is something straightforward that I'm doing wrong. I saw something online
I know this probably really simple but Im not sure what im doing wrong...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.