I converted ruby hash data to xml. My xml includes key type such as type="integer"
<problemID type="integer">3</problemID>
How can I remove the type information from my xml? such as the line below
<problemID>3</problemID>
Here is my code which generates xml from hash data.
my_xml = my_hash.to_xml(:root => 'problem')
Thanks alot.
Use skip_types: true
:
my_hash = {problemID: 3}
my_xml = my_hash.to_xml(:root => 'problem', skip_types: true)
puts my_xml
# <?xml version="1.0" encoding="UTF-8"?>
# <problem>
# <problemID>3</problemID>
# </problem>
From the documentation:
Unless the option
:skip_types
exists and is true, an attribute “type” is added as well according to the following mapping:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With