nil이 XmlSimple을 막을 것이므로루비에서 일부 값이 0 일 때 XmlSimple을 사용할 수 있습니까?
>> require 'xmlsimple'
=> true
>> XmlSimple.xml_out([{'a' => 1}, {'a' => 3}])
=> "<opt>\n <anon a=\"1\" />\n <anon a=\"3\" />\n</opt>\n"
그러나 다음과 같은 경우 오류가 발생합니다.
>> XmlSimple.xml_out([{'a' => 1}, {'a' => nil}])
ArgumentError: Use of uninitialized value!
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:798:in `value_to_xml'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:794:in `each'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:794:in `value_to_xml'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:848:in `value_to_xml'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:842:in `each'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:842:in `value_to_xml'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:807:in `value_to_xml'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:794:in `each'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:794:in `value_to_xml'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:239:in `xml_out'
from /Library/Ruby/Gems/1.8/gems/xml-simple-1.0.12/lib/xmlsimple.rb:259:in `xml_out'
from (irb):4
무엇을 의미합니까? 그것은 빈 문자열을 출력해야합니까? 또는 속성을 모두 생략해야합니까? –
방금이 똑같은 문제가 발생했습니다. 맞습니다. 그렇지 않으면 nil이 속성을 생략하기를 바랐습니다. – adamnickerson