0

Can XmlSimple.xml_out output XML the same way to_xml does? (instead of attributes, use tags):

> puts XmlSimple.xml_out([{'a' => 1, 'b' => 3.3}])
<opt>
  <anon a="1" b="3.3" />
</opt>

> puts ([{:a => 1, :b => 3.3}].to_xml)
<?xml version="1.0" encoding="UTF-8"?>
<records type="array">
  <record>
    <b type="float">3.3</b>
    <a type="integer">1</a>
  </record>
</records>
nonopolarity
  • 146,324
  • 131
  • 460
  • 740

1 Answers1

2

From the fine manual:

NoAttr => true | false (in + out) (handy)
When used with xml_out, the generated XML will contain no attributes. All hash key/values will be represented as nested elements instead.

When used with xml_in, any attributes in the XML will be ignored.

I think you want:

XmlSimple.xml_out([{'a' => 1, 'b' => 3.3}], 'NoAttr' => true)

That should give you something closer to what to_xml does but you won't get the type attributes.

mu is too short
  • 426,620
  • 70
  • 833
  • 800