2010-09-02 60 views

回答

2

引入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