Skip to content

Instantly share code, notes, and snippets.

@oogali
Created October 20, 2012 16:54
Show Gist options
  • Select an option

  • Save oogali/3923992 to your computer and use it in GitHub Desktop.

Select an option

Save oogali/3923992 to your computer and use it in GitHub Desktop.
nokogiri example
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::XML open 'fbsdtest.xml'
os_type = doc.xpath('//os/type')
p os_type
puts os_type[0].attribute('arch')
__END__
marvin:~ oogali$ ruby n.rb
[#<Nokogiri::XML::Element:0x80cd3540 name="type" attributes=[#<Nokogiri::XML::Attr:0x80cd3464 name="arch" value="i686">, #<Nokogiri::XML::Attr:0x80cd3450 name="machine" value="rhel6.2.0">] children=[#<Nokogiri::XML::Text:0x80cd2e38 "hvm">]>]
i686
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment