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 6749335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:40:42+00:00 2026-05-26T12:40:42+00:00

Sorry to bother you with such a simple question, but I’m stuck here since

  • 0

Sorry to bother you with such a simple question, but I’m stuck here since an hour:

I have an xml file that looks something like this:

<?xml version="1.0" encoding="utf-8"?>
<aaa xmlns="http://blabla.com/xmlschema/v1">

  <bbb>
    <ccc>Foo</ccc>
  </bbb>

  <ddd x="y" />
  <ddd x="xx" />
  <ddd x="z" />

</aaa>

I’m trying to access the elements ‘ddd’ like this:

var doc = new XmlDocument();
doc.Load("example.xml");
foreach (XmlNode dddNode in doc.DocumentElement.SelectNodes("//ddd"))
{
   // do something
   Console.WriteLine(dddNode.Attributes["x"].Value);
}

At runtime the foreach loop is skipped because I don’t get any nodes back from the .SelectNodes method. I breaked before the loop and had a look at the InnerXML, that looks fine, and I also tried all sorts of XPaths (like “//bbb” or “/aaa/ddd”), but only “/” seems to not return null.

This exact code worked for me before, now it does not. I suspect something with that namespace declaration in the aaa tag, but I couldn’t figure out why this should cause problems. Or.. can you see anything I may be missing?

  • 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-26T12:40:42+00:00Added an answer on May 26, 2026 at 12:40 pm

    This is xml-namespaces. There is no ddd. There is, however, x:ddd where x is your alias to http://blabla.com/xmlschema/v1. You’ll need to test with namespaces – for example:

    var nsmgr = new XmlNamespaceManager(doc.NameTable);
    nsmgr.AddNamespace("x", "http://blabla.com/xmlschema/v1");
    var nodes = doc.DocumentElement.SelectNodes("//x:ddd", nsmgr);
    // nodes has 3 nodes
    

    Note x in the above is arbitrary; there is no significance in x other than convenience.

    This (rather inconveniently) means adding the namespace (or an alias, as above) into all of your xpath expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am sorry to bother you with such a simple question but this
Sorry to bother you folks. But i have a simple question. Ho can I
Sorry to bother with such a stupid question, but I'm teaching myself PHP and
Sorry to bother you with this question, but I have a question regarding quota
Sorry to bother - perhaps this is a very simple question - but for
I'm terribly sorry to post this question here, but RedCOMPONENT just does not bother
I'm sorry to bother you with this, but i'm stuck with it for too
Sorry for this simple question, but I can't solve it... There is an example:
sorry for the dummy question but I cannot find a simple and clean way
Sorry to bother you all here but I am still trying to understand more

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.