Suppose I have the following HTML:
html = Four score and seven <b>years ago</b>
I want to parse this with Hpricot:
doc = Hpricot(html)
Find the <b>
node:
node = doc.at('b')
and then get the character index of the <b>
node within its parent:
node.character_index
=> 22
How can I do this (i.e., what's the real version of the character_index()
function I just made up)?