鲁比:是简单的奇怪行为还是做错了? 需要“rubygems” 需要“xmlsimple” data=XmlSimple.xml_in(“12341234Some text here,11234.and here,234.and here”) 放置数据['Title']。是否为?排列

鲁比:是简单的奇怪行为还是做错了? 需要“rubygems” 需要“xmlsimple” data=XmlSimple.xml_in(“12341234Some text here,11234.and here,234.and here”) 放置数据['Title']。是否为?排列,ruby,Ruby,为什么它是数组而不是字符串?欧欧欧 谢谢;) 使用: require 'rubygems' require 'xmlsimple' data = XmlSimple.xml_in("<Product><ProductId>12341234</ProductId><Title>Some text here, 11234. and here, 234. and here </Title></Product>") puts da

为什么它是数组而不是字符串?欧欧欧

谢谢;)

使用:

require 'rubygems'
require 'xmlsimple'

data = XmlSimple.xml_in("<Product><ProductId>12341234</ProductId><Title>Some text here, 11234. and here, 234. and here </Title></Product>")
puts data['Title'].is_a? Array
默认情况下,选项为
true
,因为通常您希望嵌套元素被折叠成散列

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