HpricotとRubyを使用してHTMLファイルを解析しようとしていますが、のようなタグで囲まれていない「フリーフローティング」テキストの抽出に問題があります<p></p>
。
require 'hpricot'
text = <<SOME_TEXT
<a href="http://www.somelink.com/foo/bar.html">Testing:</a><br />
line 1<br />
line 2<br />
line 3<br />
line 4<br />
line 5<br />
<b>Here's some more text</b>
SOME_TEXT
parsed = Hpricot(text)
parsed = parsed.search('//a[@href="http://www.somelink.com/foo/bar.html"]').first.following_siblings
puts parsed
結果は次のようになると思います
<br />
line 1<br />
line 2<br />
line 3<br />
line 4<br />
line 5<br />
<b>Here's some more text</b>
しかし、私は得ています
<br />
<br />
<br />
<br />
<br />
<br />
<b>Here's some more text</b>
Hpricotのリターンライン1、ライン2などを作成するにはどうすればよいですか?