hpricot:An Hpricot Showcase:Hpricot Challenge:Preceding / Following Children?

まんま

require "hpricot"

X =<<EOS
<div>
  <A>...</A>
  ...
  <B>...</B>

  <a name='articlestart'> </a>

  <C>...</C>
  ...
  <D>...</D>
</div>
EOS

doc = Hpricot(X)
p doc.at('//a[@name="articlestart"]')
p doc.at('//a[@name="articlestart"]').following_siblings

で、

{elem <a name="articlestart"> " " </a>}
#<Hpricot::Elements[{elem <c> "..." </C>}, {elem <d> "..." </D>}]>