• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Having trouble coming up with an xpath statement foe this

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I am having a bit of trouble coming up with an xpath statement for this problem. It doesn't even have to be xpath actually, but I thought using xpath would be easiest.

here is part of a Dom Document I have



I'm pretty sure an anchor inside an anchor is not valid, but the html sanitizer takes care of that so it is alright. The person tag was added by a third party library.

Now what I want returned is this exactly
"text2<em>text3</em><b>text4</b>"

I have a reference to the <person> tag from a previous xpath statement if that helps. Lets say Node n holds a reference to <person>. So far i use something like



but the problem with this is it returns "texttext2text3text4"

What xpath statement will get me

text2<em>text3</em><b>text4</b>

?
It doesn't necessarily have to be xpath. If another way works better, I can use that.

Thanks
 
Sheriff
Posts: 26765
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming that your outer <a> element is the context node, this would work:

Bear in mind that any XPath expression will return a list of nodes. Do you want this list of nodes serialized to the text that your post seems to suggest, or is the list of nodes good enough?
 
reply
    Bookmark Topic Watch Topic
  • New Topic