Refactor xml_document.rb