views:

38

answers:

1

I have to write an XPath expression to get the href attribute of the anchor tag in the html bellow that comes right after the one that is marked as "current-page" (in the example #notimportant/2).

<dd>
    <a href="#notimportant/1" class="current-page">1</a>
    <a href="#notimportant/2">2</a>
    <a href="#notimportant/3">3</a>
    <a href="#notimportant/4">4</a>
    <!-- EDIT: Do not return the next sibling if @href ends with /last -->
    <a href="#notimportant/last">last</a>
</dd>

I thought about starting with something like //a[@class='current-page']/../next-sibling-of-first-node/@href but I am stuck here...

Could anyone help me with this one? I have googled around but XPath is not my favorite skill (and no, I can't use jQuery. it is not a webapp).

+4  A: 
//a[@class='current-page']/following-sibling::a[1]
Matthew Flaschen
+1, amazing answer, @Matthew! 9 seconds =)
Rubens Farias
Guys, you are too fast for me. :-P
Tomalak
Thanks guys. That was super fast. I have edited my question, would you mind reviewing the answer?
pablo