1
我正在使用rake任务中的xml-simple gem来解析数据库转储的内容。问题在于数据库xml文件包含像标题中那些导致xml-simple崩溃的字符。有没有解决这个问题?解析<first_name>João</first_name>使用xml-simple
我正在使用rake任务中的xml-simple gem来解析数据库转储的内容。问题在于数据库xml文件包含像标题中那些导致xml-simple崩溃的字符。有没有解决这个问题?解析<first_name>João</first_name>使用xml-simple
引入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ão