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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:20:45+00:00 2026-06-18T17:20:45+00:00

Hi I have xml file (which is actually msbuild file) that uses different namespace

  • 0

Hi I have xml file (which is actually msbuild file) that uses different namespace

<?xml version="1.0" ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup Condition="'$(key)'=='1111'">
          <Key>Value</Key>
    </PropertyGroup>
</Project>

But the problem is I can’t use SelectSingleNode with that file because of

xmlns="http://schemas.microsoft.com/developer/msbuild/2003"

I believe it’s since default namespace (necessary for the method) is gone because of xmlns above. Then I think I just need to add necessary one for that.. But my tries weren’t successful at all. Could you please give me a quick example how to do this?

Here is how I did. (I also tried to added multiple namespaces but weren’t successful..)

XmlDocument xml = new XmlDocument();
xml.Load("ref.props");        
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("msbld", "http://schemas.microsoft.com/developer/msbuild/2003");

XmlNode platform_node
  = xml.SelectSingleNode("//msbld:PropertyGroup[contains(@Condition, '1111')]", nsmgr);
  • 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-18T17:20:46+00:00Added an answer on June 18, 2026 at 5:20 pm

    You need to use the correct namespace, which is “http://schemas.microsoft.com/developer/msbuild/2003“.

    Try

    XmlDocument xml = new XmlDocument();
    xml.Load("ref.props");        
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
    nsmgr.AddNamespace("ms", "http://schemas.microsoft.com/developer/msbuild/2003");
    
    XmlNode platform_node
      = xml.SelectSingleNode("/ms:Project/ms:PropertyGroup[contains(@Condition, '1111')]",
                             nsmgr);
    

    Don’t confuse the namespace prefix (which was empty in the XML) with the namespace, which is “http://schemas.microsoft.com/developer/msbuild/2003“.

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

Sidebar

Related Questions

I have an Xml File as below: <?xml version=1.0 encoding=UTF-8 standalone=yes?> <ea:Stories ea:WWVersion=2.0 xmlns:aic=http://ns.adobe.com/AdobeInCopy/2.0
I have the following xml file: <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/FrameLayout android:layout_width=match_parent android:layout_height=match_parent
i have that xml file : <?xml version=1.0 encoding=utf-8?> <reminders> <reminder> <Title>Alarm1</Title> <Description>Desc1</Description> <Time>03/07/2012
I have the following XML file (it's actually VS2010 dbproj file) <?xml version=1.0 enconding=utf-8?>
I have a file called build_properties.xml in my Java project, which is not a
I have a xml file which I need to open with Microsoft Word 2007.
I have this xml file which has text init. i.e Hi my name is
I have an XML file which I need to parse using PHP and send
I have an XML file which XML parser choke on. A part of it
I have an XML file which has many section like the one below: <Operations>

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.