欢迎来到cool的博客
7

Music box

Click to Start

点击头像播放音乐
新博客链接

rails使用Hash.from_xml 解析xml

xml = <<-XML 
<?xml version="1.0" encoding="UTF-8"?>
 <hash> 
  <foo>1</foo> 
  <bar>2</bar>
 </hash> 
XML 

hash = Hash.from_xml(xml) # => {"hash"=>{"foo"=>1, "bar"=>2}}

然后解析成自己想要的json或者array

https://ruby-china.org/topics/30854

返回列表