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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:08:50+00:00 2026-05-29T06:08:50+00:00

I am looking for an example of a XQuery that returns the xpath for

  • 0

I am looking for an example of a XQuery that returns the xpath for each node found. So for example instead of getting the text() of each found node I would like to get the path() – but that function doesn’t seem to exist 🙂

I see now that the XPath 3.0 spec defines a path() function that would do what i want, but apparently this is new to 3.0

http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/#func-path

  • 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-29T06:08:50+00:00Added an answer on May 29, 2026 at 6:08 am

    As Martin Honnen commented, the XPath expression selecting a specific node isn’t unique. For example, the second y element in the following document

    <x>
      <y id="1"/>
      <y id="2"/>
    </x>
    

    could be selected (non-exclusively) by:

    //y[2],
    /x/y[2],
    //*[@id = '2'],
    /x/*[position() = last()]
    

    If you are just interested in getting some XPath expression selecting the node, the FunctX XQuery Function Library contains two functions that do that:

    • functx:path-to-node
      returns an XPath expression that selects all nodes with the same name and
      ancestor names as the node you evaluate it for.

      In our example it would return x/y for both y elements (mind the missing leading slash).

    • functx:path-to-node-with-pos also includes the position of each ancestor in the document, thereby only selecting the node you pass in.

      In the example, the first y element would produce x/y[1] and the second one x/y[2].

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

Sidebar

Related Questions

I'm looking for example of how I would solve the scenario below: Imagine my
Looking for an example that: Launches an EXE Waits for the EXE to finish.
So I've spent all day looking for good examples of using xpath / xquery
I found a decent looking example of how to call a delegate asynchronously with
I'm looking at example of using hadlebars.js, where template processing looks like: var source
Looking at example under Pointers to classes (very bottom) How is it that we
I looking for example of program, that modifies a string inside its exe. I
I am looking for example code that provides a unit test to serialize and
I am looking for example Java code that can construct an XML document that
I am looking for example code sample that shows how to achieve 30 frames

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.