hpricot:An Hpricot Showcase:Hpricot Challenge:Follow-up to `Preceding/Following Children' (text nodes)
まんま
require "hpricot" X =<<EOS <div> <A>...</A> ... <B>...</B> <a name='articlestart'> </a> <C>...</C> Some text <tag> </tag> More text Even more text <D>...</D> </div> EOS doc = Hpricot(X) p doc.at('//a[@name="articlestart"]') p doc.at('//a[@name="articlestart"]').following_siblings p doc.at('//a[@name="articlestart"]').next p doc.at('//a[@name="articlestart"]').next_sibling p doc.at('//a[@name="articlestart"]').next_node
で、
{elem <a name="articlestart"> " " </a>} #<Hpricot::Elements[{elem <c> "..." </C>}, {elem <tag> " " </tag>}, {elem <d> "..." </D>}]> "\n\n " {elem <c> "..." </C>} "\n\n "