Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created January 6, 2011 05:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tenderlove/767556 to your computer and use it in GitHub Desktop.
Save tenderlove/767556 to your computer and use it in GitHub Desktop.
require 'nokogiri'
doc = Nokogiri.HTML DATA
p doc.xpath('//div//text()').map { |x| x.to_html }
__END__
<html>
<body>
<div>&nbsp;<span>x</span></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment