Apply most of patch from Pavel Valodzka.
Apply most of patch from Pavel Valodzka.

xml4r/libxml-ruby,xml4r/libxml-ruby,increments/libxml-ruby,increments/libxml-ruby,sferik/libxml-ruby,sferik/libxml-ruby,xml4r/libxml-ruby,sferik/libxml-ruby,sferik/libxml-ruby,sferik/libxml-ruby,sferik/libxml-ruby,increments/libxml-ruby