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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:09:35+00:00 2026-05-18T12:09:35+00:00

I know this is a somewhat easy question, but I haven’t been able to

  • 0

I know this is a somewhat easy question, but I haven’t been able to make it work even after looking at answers on SO and LINQ to XML tutorials. I’m using Windows Phone 7, but I don’t think that should make a difference.

I have XML that looks like this:

<response xmlns="http://anamespace.com/stuff/">
    <error code="ERROR_CODE_1">You have a type 1 error</error>
</response>

I have the XML above loaded into an XElement. I want to get the “error” node. This question says you need to handle the namespace. I’ve tried my query with and without the namespace and it doesn’t work either way.

Query with namespace:

private object ParseElement(XElement responseElement)
{
    XNamespace ns = "http://anamespace.com/stuff/";
    IEnumerable<XElement> errorNodes = from e in responseElement.Elements(ns + "error") select e;
}

Query without namespace:

private object ParseElement(XElement responseElement)
{
    IEnumerable<XElement> errorNodes = from e in responseElement.Elements("error") select e;
}

The errorNodes variable never gets populated with XElements. The tutorials I’ve read all use this notation for selecting an element by name, but it’s not working for me.

  • 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-18T12:09:36+00:00Added an answer on May 18, 2026 at 12:09 pm

    This codes Works on my Machine™:

    XElement response = XElement.Parse(
    @"<response xmlns=""http://anamespace.com/stuff/"">
        <error code=""ERROR_CODE_1"">You have a type 1 error</error>
    </response>");
    
    XNamespace ns = "http://anamespace.com/stuff/";
    
    XElement error = response.Element(ns + "error");
    
    string code = (string)error.Attribute("code");
    string message = (string)error;
    
    Console.WriteLine(code);
    Console.WriteLine(message);
    

    My machine runs regular .NET 4 though, so maybe you can run this code and check if it works for WP7.

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

Sidebar

Related Questions

I'm somewhat new to Ajax/Jquery, so I apologize if this is an easy question,
I know this is a somewhat common subject, but the information is outdated quickly.
I am a somewhat experienced rubyist, but I am now starting to do rails
I have a list of items that is somewhat like this: [ [orange, 9],
(This is somewhat a follow-up on Android: How do you scale multiple views together?
I'm still somewhat new to WPF (only done a few small projects with it).
What I'm trying is this: 1) Create a new manged object 2) Get it's
I'm looking into speeding up my python code, which is all matrix math, using
Background I'm writing a graphing library for an android application (yes yes, I know
Can anybody please describe about how to implement threading in PHP programming? What I

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.