Skip to content

Instantly share code, notes, and snippets.

@flavorjones
Created July 16, 2010 15:19
Show Gist options
  • Save flavorjones/478479 to your computer and use it in GitHub Desktop.
Save flavorjones/478479 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
html = "<html><body><div>hello</div></body></html>"
doc = Nokogiri::HTML html
div = doc.at_css "div"
div.inner_html = "hello"
div # => #<Nokogiri::XML::Element:0x3f97a8656614 name="div" children=[#<Nokogiri::XML::Text:0x3f97a8655d54 "hello">]>
div.inner_html = "this ** guy"
div # => #<Nokogiri::XML::Element:0x3f97a8656614 name="div" children=[#<Nokogiri::XML::Text:0x3f97a8654ecc "this ** guy">]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment