-
-
Save leejarvis/b018c3da03aca32dfc62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
doc = Nokogiri.HTML DATA | |
root_node = doc.at('font') | |
headline = doc.at('strong') | |
before = root_node.at('./text()[(following::br)]') | |
after = headline.at('./following::br/following::text()') | |
p before.text.strip #=> "Some foo bar text" | |
p headline.text.strip #=> "something" | |
p after.text.strip #=> "some other foo bar text" | |
__END__ | |
<font size="2" face="Microsoft Sans Serif"> | |
Some foo bar text | |
<br><br> | |
<strong>something</strong> | |
<br><br> | |
some other foo bar text | |
</font> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment