Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get last parent of a particular type?

 
kapil Gupta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your XPath expression for that would be something like
 
kapil Gupta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic