Skip to content

Instantly share code, notes, and snippets.

@nrk
Created January 27, 2009 14:31
Show Gist options
  • Save nrk/53361 to your computer and use it in GitHub Desktop.
Save nrk/53361 to your computer and use it in GitHub Desktop.
Hpricot on IronRuby
require 'hpricot'
xml =<<XML
<items>
<item number="1">
<name>item #1</name>
</item>
<item number="2">
<title>item #2</title>
</item>
</items>
XML
puts "--- #{RUBY_ENGINE} ---"
Hpricot.scan(xml) { |token| p token }
--- ironruby ---
[:stag, "items", nil, "<items>"]
[:text, "\n ", nil, "\n "]
[:stag, "item", {"number"=>"1"}, "<item number=\"1\">"]
[:text, "\n ", nil, "\n "]
[:stag, "name", nil, "<name>"]
[:text, "item #1", nil, "item #1"]
[:etag, "name", nil, "</name>"]
[:text, "\n ", nil, "\n "]
[:etag, "item", nil, "</item>"]
[:text, "\n ", nil, "\n "]
[:stag, "item", {"number"=>"2"}, "<item number=\"2\">"]
[:text, "\n ", nil, "\n "]
[:stag, "title", nil, "<title>"]
[:text, "item #2", nil, "item #2"]
[:etag, "title", nil, "</title>"]
[:text, "\n ", nil, "\n "]
[:etag, "item", nil, "</item>"]
[:text, "\n", nil, "\n"]
[:etag, "items", nil, "</items>"]
[:text, "\n", nil, "\n"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment