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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:50:06+00:00 2026-05-13T23:50:06+00:00

i will give an example of the problem i have. My XML is like

  • 0

i will give an example of the problem i have. My XML is like this

<root>
  <child Name = "child1">
  <node>
  <element1>Value1</element1>
  <element2>Value2</element2>
  </node>
  </child>
  <child Name = "child2">
  <element1>Value1</element1>
  <element2>Value2</element2>
  <element3>Value3</element3>
  </child>
</root>

I have xpath expression that returns all “element2” nodes. Then i want to for every node of type “element2” to find the node of type “child” that contains it. The problem is that between these two nodes there can be from 1 to n different nodes so i can’t just use “..”. Is there something like “//” that will look up instead of down

I have some basic knowledge of xpath and according http://www.w3schools.com/xpath/xpath_syntax.asp “..’ returns current node parent the problem is that the current node is “element2” and the problem is that the xml is dynamic comes from third party library so i can have xml like this

<child Name = "child1">
  <node>
  <element1>Value1</element1>
  </node>
</child>

or like this

<child Name = "child1">
  <node1>
   <node2>
    <node3>
     <element1>Value1</element1>
     <element2>Value2</element2>
    </node3>
   </node2>
  </node1>
</child>

There can be more then 3 nodes between “element” and child an the number of nodes vary form 1 to 20. Please give me an example of just one xpath query to get the “child” node in both cases using just “..”

Best Regards,
Iordan

  • 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-13T23:50:06+00:00Added an answer on May 13, 2026 at 11:50 pm

    So your current context is the element2 element? Use the parent axis:

    parent::child/@Name
    

    That will get the parent of the current element, named child, and get its attribute Name.

    If you’re not in the context of element2 and you want to find all child elements with element2 children, you need this one instead:

    child[element2]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, here on stack overflow the URL https://stackoverflow.com/questions/tagged/javascript+php will give you all questions
In traditional embedded programming, we will give a delay function like so: for(i=0;i<255;i++) for(j=0;j<255;j++);
here is my problem I have the following array (for example) string[] arr =
Is there a built in dll that will give me a list of links
Is there a POSIX function that will give me the size of a directory
Is there a command within the bash shell of fedora that will give me
I'm trying to write a unit test for a module that will give me
I am considering creating some JSP-tags that will always give the same output. For
Will I have to pay again? I have about 9 months left before renewal
Can anyone give me an example of successful non-programmer, 5GL (not that I am

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.