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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 93k
  • Answers 93k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Refreshing the page (pressing F5) is different than a postback.… May 11, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer Write the first line: %macro(200701);x gzip /home/test/200701.txt;run; Then, while still… May 11, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer If you have used the Visual Studio generators and everything… May 11, 2026 at 6:43 pm

Related Questions

I looked in the Rails docs under inflector and found this message... Module deprecated
I am trying to load an image in the background and then update the
I'm wondering if someone can point me in the right direction. I've got an
In one of my projects I need to build an ASP.NET page and some

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.