This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring 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
Pie
Posts: 20719
30
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