Vairoj writes

Installing libxml-ruby on Windows: The painless way

Most of the pages I googled for how to install LibXml Ruby on Windows mention building the required libraries on Windows. Not only that it is a hassle, but I could not make it works either. I finally found a straightforward way and hope it can save you some time.

UPDATE: As you guys pointed out in the comments, I updated the instruction with some more detail and steps that I didn't mention previously.

  1. Prerequisite: Make sure that you already have rake installed.

    gem install rake

    You also probably need Ruby DevKit in order to install native libraries. Follow DevKit Installation Instructions on its wiki page.

  2. As mentioned on LibXml RDoc, you need to download Win32 RubyGem which includes all the required binaries. This way you don't have to go through the hassle of building all the libraries yourself. To install libxml with prebuilt binaries for Windows, executing the following command: (Thanks @Carl for the suggestion)

    gem install libxml-ruby --platform x86-mswin32-60

    If there is error at this step make sure you have DevKit installed.

  3. The DLLs must also be available in PATH environment variable. Assuming that your <ruby-path>\bin is already in your PATH (as set by RubyInstaller), copy libxml2-2.dll and libiconv2.dll from <ruby-path>\lib\gems\1.8\gems\libxml-ruby-xxx\lib to your <ruby-path>\bin directory. Your <ruby-path> should be something like C:\Ruby187.

  4. Test if everything works by entering irb and require both rubygems and libxml.

    irb(main):001:0> require 'rubygems'
    => true
    irb(main):002:0> require 'libxml'
    => true
    irb(main):003:0>

And that's it. Now you should be able to use LibXml with your Ruby code!