开发者

Ruby: XmlSimple strange behavior or doing it wrong?

开发者 https://www.devze.com 2023-03-09 02:40 出处:网络
require \'rubygems\' require \'xmlsimple\' data = XmlSimple.xml_in(\"<Product><ProductId>12341234</ProductId><Title>Some text here, 11234. and here, 234. and here </Title&g
require 'rubygems'
require 'xmlsimple'

data = XmlSimple.xml_in("<Product><ProductId>12341234</ProductId><Title>Some text here, 11234. and here, 234. and here </Title>开发者_Go百科;</Product>")
puts data['Title'].is_a? Array

Why it's an array instead of string? O_o

Thanks ;)


Use:

data = XmlSimple.xml_in yourxml, { 'ForceArray' => false}

The options is true by default because normally you want nested elements be folded into hashes.

0

精彩评论

暂无评论...
验证码 换一张
取 消