I have the following html structure:
<p><b> Some bold text which starts with xy <b>
<p> text
<p> text
<p><b> Next bold text <b>
<p> text
<p> text
I need to construct an xpath which grasps all text after the bold text which starts with xy ONLY until the next bold text which does not start with xy. My attempts so far:
"//p/*[starts-with(text()),'xy']/following::text()"
Yet, this grasps all text - also that after the next bold text which does not start with xy. Any suggestions?
I have found a solution which seems to work:
"//p/b[starts-with(.,'xy')]/following::p[count(preceding::b) = 1]"
So, the trick is here the counter. The trade-off is that by setting the counter for all preceding b at 1, it will not go further than the first b after the b which starts with xy, yet, it also includes the text in that b. This can certainly be improved but it is ok for my purposes now.