我在rake任务中使用xml-simple gem来解析db转储的内容。问题是数据库xml文件包含的字符与标题中的字符类似,这会导致xml-simple崩溃。有什么办法可以解决这个问题吗?
发布于 2010-09-03 09:34:17
Nokogiri似乎起作用了:
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ãohttps://stackoverflow.com/questions/3631500
复制相似问题