dcsimg
July 19, 2018
Hot Topics:

Parsing XML with Hpricot, a Gem of a Ruby Gem

  • January 5, 2010
  • By Jason Gilmore
  • Send Email »
  • More Articles »

XML is often touted as being "human readable." In fact, the goal was to avoid having to spend too much time trying to parse the language at all. However, XML often falls short of that goal. Luckily for Ruby developers, a quick search for a parsing solution will turn up Hpricot. This Ruby gem can parse and manipulate XML with amazing flexibility and ease.

In his Web Developer's Virtual Library (WDVL) tutorial, Jason Gilmore introduces Hpricot, showing you how to begin using this powerful gem in ways that will leave you with plenty of time to read something far more exciting than XML.

Installing the Hpricot Gem

Hpricot is packaged as a Ruby gem, meaning the easiest way to install it is to use the RubyGems package manager. Of course, this also means you'll need to install Ruby, so take care of that now if Ruby's not already installed on your system.

Next, install Hpricot by opening a terminal window and executing the following command:

%>gem install hpricot

You can confirm Hpricot installed correctly by firing up the interactive ruby shell, better known as the irb, and using the require method to load the Hpricot library:

%>irb
irb(main):001:0> require 'hpricot'
=>true
irb(main):002:0>

With Hpricot installed, you're ready to begin parsing XML! Read the entire tutorial on parsing XML with Hpricot on WDVL.






Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

Thanks for your registration, follow us on our social networks to keep up-to-date