1

I am using the xml-simple gem inside a rake task to parse the contents of a db dump. The problem is that the database xml file contains characters like those in the title that causes xml-simple to crash. Is there a work around to this?

Eric M.
  • 5,399
  • 6
  • 41
  • 67

1 Answers1

2

Nokogiri seems to work:

require 'nokogiri'

xml =<<ENDOFxML
  <test>
    <first_name>João</first_name>
  </test>
ENDOFxML

doc = Nokogiri::XML.parse(xml)
doc.xpath('//first_name').each do |node|
  puts node.inner_text
end

#Output: João
Mark Thomas
  • 37,131
  • 11
  • 74
  • 101