2011-05-30 52 views
2
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 

爲什麼它是一個數組而不是字符串? O_ORuby:Xml很奇怪的行爲還是做錯了?

感謝;)

回答

2

用途:

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

的選項是true默認因爲通常你想嵌套元素摺疊成的哈希值。

+0

感謝隊友;)+1 – Somebody 2011-05-30 20:41:05

+0

歡迎您! – 2011-05-30 20:45:06