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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:23:14+00:00 2026-05-28T14:23:14+00:00

Could anyone please provide XPath expression which selects all nodes that have explicit ‘xmlns’

  • 0

Could anyone please provide XPath expression which selects all nodes that have explicit ‘xmlns’ attribute, e.g. <html xmlns="http://www.w3.org/1999/xhtml">? //*[@xmlns] does not work because (as it turned out) xmlns is not treated as attribute by XPath.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>Информация по счетам, картам</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="pragma" content="no-cache"/>
.......

I need only ‘html’ node here.

  • 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-28T14:23:14+00:00Added an answer on May 28, 2026 at 2:23 pm

    The technically correct answer is that it’s…

    Not possible. You need to distinguish between the abstract document that the source text represents and the actual source text itself. XPath operates on the abstraction, not on the source text, and the location of the xmlns pseudo-attribute is only relevant in the latter.

    However…

    You could sort of fake it with the following XPath 2.0 expression:

    //*[not(namespace-uri()=ancestor::*/namespace-uri())]
    

    This selects any element that does not have an ancestor in the same namespace, which theoretically means that it selects all elements where the namespace is declared. However, it won’t catch namespaces that are re-declared. For example, consider this document:

    <html xmlns="http://www.w3.org/1999/xhtml">
        <head/>
        <body>
            <p xmlns="http://something">
                <p xmlns="http://something"/>
            </p>
        </body>
    </html>
    

    The expression above selects the html element and the first p. The second p has an ancestor in the same namespace, so it’s not selected, even though it specifies an xmlns.

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

Sidebar

Related Questions

Could anyone please give a sample or any link that describes how to spawn
Update I want to have an expression (XPath, or Regex Expression, similar) that can
Could anyone please provide an explanation of the syntax in the following example, or
Could anyone please provide me with guidance on whether it's possible to use aspNetActiveDirectoryProvider
Could anyone please tell me the meaning of API in following paragraph, that's actually
Could anyone please provide resources on how to reset password in Java web application
could anyone please provide on how to achieve below scenario ? 2 queues -
Could anyone please tell what are the important use cases of IdentityHashMap ?
could anyone please clarify the meaning of line generalizes the tag object's storage of
Could anyone please tell me why the following line about filter init method invocation

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.