This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "query on parent axis in xpath" Watch "query on parent axis in xpath" New topic
Author

query on parent axis in xpath

Sudarshan Sreenivasan
Ranch Hand

Joined: Jun 28, 2007
Posts: 188

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
Sheriff

Joined: Oct 14, 2005
Posts: 19719
    
  10

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.
Sudarshan Sreenivasan
Ranch Hand

Joined: Jun 28, 2007
Posts: 188

Thanks, I was reading the expression wrongly !

Yes that was my entire document



This returns to me what i need.
 
Have you checked out Aspose?
 
subject: query on parent axis in xpath
 
It's not a secret anymore!