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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:02:17+00:00 2026-06-08T23:02:17+00:00

Namespaces and XML are still confusing the hell out of me. Here is my

  • 0

Namespaces and XML are still confusing the hell out of me.

Here is my XML (that comes from a SOAP request)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <MyResponse xmlns="http://tempuri.org/">
         <OutputXML xmlns="http://tempuri.org/XMLSchema.xsd">
            <Result>
               <OutputXML>
                  <Result>
                     <Foo>
                        <Bar />
                     </Foo>
                  </Result>
               </OutputXML>
            </Result>
         </OutputXML>
      </MyResponse>
   </soap:Body>
</soap:Envelope>

I am trying to extract the actual XML part from the SOAP response (starting with the Foo element):

var nsmgr = new XmlNamespaceManager(document.NameTable);
nsmgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
nsmgr.AddNamespace("", "http://tempuri.org/");
nsmgr.AddNamespace("", "http://tempuri.org/XMLSchema.xsd");

var xml = document.DocumentElement
    .SelectSingleNode("Foo", nsmgr)
    .InnerXml;

But SelectSingleNode returns null. I’ve tried some different variations on this but can’t get anything working. What am I not understanding?

  • 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-06-08T23:02:19+00:00Added an answer on June 8, 2026 at 11:02 pm

    Try this one:

    var nsmgr = new XmlNamespaceManager(document.NameTable);
    nsmgr.AddNamespace("aaa", "http://tempuri.org/XMLSchema.xsd");
    
    var xml = document.DocumentElement
        .SelectSingleNode("aaa:Foo", nsmgr)
        .InnerXml;
    

    this is because of Default namespaces has no perfix.

    You can use GetElementsByTagName to use namespace uri directly:

    var xml = document.GetElementsByTagName("Foo", 
                 "http://tempuri.org/XMLSchema.xsd")[0].InnerXml;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?xml version=1.0 encoding=UTF-8?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:aop=http://www.springframework.org/schema/aop xmlns:context=http://www.springframework.org/schema/context xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.1.xsd>
I need to unmarshall an XML that has namespaces for the attributes, for instance
I've tried to read http://www.w3.org/TR/xml-infoset/ and the wikipedia entry . But frankly I'm still
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and
Do you use a naming convention for your XML namespaces? And if so, what
I am using the DOM extension to parse an xml file containing xml namespaces
I want to learn how to process XML with namespaces in E4X so basically
Is there an smart way of unqualifing (clean namespaces references) a XML in c#?
Hi I am trying to get my mind around XSDs, XML and namespaces but
I have following XML. I was able to remove all namespaces but not able

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.