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