-
-
Save oogali/3923992 to your computer and use it in GitHub Desktop.
nokogiri example
This file contains hidden or 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 '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