File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How to get last parent of a particular type? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to get last parent of a particular type?" Watch "How to get last parent of a particular type?" New topic
Author

How to get last parent of a particular type?

kapil Gupta
Ranch Hand

Joined: Dec 17, 2001
Posts: 89
Hi,
I have a requirement to get value of an attribute of a parent node but the index of parent node is dynamic.
For example:

I need to get span class while processing bold, italic and strike tags.
As the order of these html tags may change, I cannot predict the index of parent.
Is there a way to get last parent node of type span?
Thanks,
Kapil
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Your XPath expression for that would be something like
kapil Gupta
Ranch Hand

Joined: Dec 17, 2001
Posts: 89
Thanks Paul. How can I I check if the parent axis upto span node contains a specific node? For example if the html is of type


While processing underline node, I need to check if the text has parent node of type bold and italic. Right now am using following code for this

But since the nesting level may vary I cannot predict the position.
Thanks,
Kapil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get last parent of a particular type?