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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:06:56+00:00 2026-05-29T04:06:56+00:00

The question(s): Can a XPath 1.0 expression return only the names of xml nodes

  • 0

The question(s):
Can a XPath 1.0 expression return only the names of xml nodes (either qualified or not) and not the entire node? Is XPath 2.0 capable of same?


The detail:

I am profiling a series of well-formed xml documents for xml element node usage (ie. obtain aggregate counts of xml nodes across several xml documents). I have a perl script that retrieves a desired node-set of each document, then iterates over each node to obtain counts of the node names using the XML::XPath::Node::Element->getName. I have an alternate implementation that profiles xml node attributes and text values, but use an XPath statement to retrieve the “atomic values” (as opposed to using XML::XPath::Node::Element->getAttribute() or similar in perl).

[Note that I realize the “atomic values” are actually sets of attribute/ text nodes.]

I experience a 50-fold improvement in performance when allowing the XPath expression to return the desired “atomic values” as opposed to looping over results in perl, so I would like to retrieve xml node names in a manner similar to attribute (ie ‘attribute::‘ or ‘@‘)and text (ie ‘text()’) nodes. I’ve looked over the XPath and XML specs, but have not been able to identify a solution.

edit: To be more specific, I’m looking for something like 'local-name(//*)', but something that returns a set of names for all matching nodes (as opposed to only the first node found).

  • 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-29T04:06:57+00:00Added an answer on May 29, 2026 at 4:06 am

    XPath 1.0 is a filter; it can’t generate content. If it’s not a node in the DOM (element node, attribute node, text node, etc), it can’t be returned. That means that strings can’t be returned by an XPath query.

    That’s why //*/local-name() can’t possibly work.

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

Sidebar

Related Questions

How can I get each node's attribute via xpath? For instance, book.xml, <?xml version=1.0
Update I want to have an expression (XPath, or Regex Expression, similar) that can
Let's imagine that I have a result of evaluating XPath expression //node/@*. MSXML6 returns
According to another question I can select individual XML fields with a YQL query
Question Can I build a image database/library that has an e-commerce style checkout system
Simple question: Can a swing frame be completely modal ( block all others windows
Simple question: Can I mix in my desktop application Java and JavaFX Script code?
this question can create a misunderstanding: I know I have to use CSS to
My question can be boiled down to, where does the string returned from stringstream.str().c_str()
Here is the question: Can TortoiseSvn work on Windows 2008 without turning off User

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.