Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes XML and Related Technologies and the fly likes query on parent axis in xpath Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "query on parent axis in xpath" Watch "query on parent axis in xpath" New topic
Author

query on parent axis in xpath

sid sree
Ranch Hand

Joined: Jun 28, 2007
Posts: 186
Hi my input xml



My xpath expression



Also tried



My expected result Hello elemet.

Actual Result No elements

Where am i going wrong ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16482
    
    2

So you started from your context node and looked for a child element whose name was Hello. Maybe you found that Hello element and maybe you didn't, depending on what your context node was. Then you looked for a parent of that node which was a Bye element. Presumably that Hello element isn't a child of any Bye element; it certainly isn't if that's your whole document.
sid sree
Ranch Hand

Joined: Jun 28, 2007
Posts: 186
Thanks, I was reading the expression wrongly !

Yes that was my entire document



This returns to me what i need.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: query on parent axis in xpath
 
Similar Threads
i want write xpath for 4 diffrent clients with two ancestors node pls help me
How to Generalize the code?
append an element to a text node using jdom?
Selecting Node from XML
apply-template params vs accessing parent attributes