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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:36:58+00:00 2026-05-10T16:36:58+00:00

What is the story behind XPath and support for namespaces? Did XPath as a

  • 0

What is the story behind XPath and support for namespaces? Did XPath as a specification precede namespaces? If I have a document where elements have been given a default namespace:

<foo xmlns='uri' /> 

It appears as though some of the XPath processor libraries won’t recognize //foo because of the namespace whereas others will. The option my team has thought about is to add a namespace prefix using regular expressions to the XPath (you can add a namespace prefix via XmlNameTable) but this seems brittle since XPath is such a flexible language when it comes to node tests.

Is there a standard that applies to this?

My approach is a bit hackish but it seems to work fine; I remove the xmlns declaration with a search/replace and then apply XPath.

string readyForXpath = Regex.Replace(xmldocument, 'xmlns=\'.+\'', String.Empty ); 

Is that a fair approach or has anyone solved this differently?

  • 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. 2026-05-10T16:36:58+00:00Added an answer on May 10, 2026 at 4:36 pm

    I tried something similar to what palehorse proposed and could not get it to work. Since I was getting data from a published service I couldn’t change the xml. I ended up using XmlDocument and XmlNamespaceManager like so:

    XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlWithBogusNamespace);             XmlNamespaceManager nSpace = new XmlNamespaceManager(doc.NameTable); nSpace.AddNamespace('myNs', 'http://theirUri');  XmlNodeList nodes = doc.SelectNodes('//myNs:NodesIWant',nSpace); //etc 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay first let me tell you the story behind the question. We have a
All, I have to manually create an HTML page. The story behind it is
Story: One of the app that i have works on python 2.4 and other
Story: I have a link which has some text. A part of the link
The story: I had class User and class Organization: User. I did not use
Long story short, I have an ASP.NET application I'm trying to debug and at
We currently have a WebForms control with an update panel. The code-behind contains logic
I am trying to select specific values from a xml document using XPath. The
I am trying to select specific values from a xml document using XPath. The
The story behind... I really like TV shows but I go back home only

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.