How to eliminate hash tag when to_xml is used

help

Hi, everyone,

I have a hash obj and when converted to xml using to_xml the
tag appears like the following

<?xml version="1.0" encoding="UTF-8"?> ...

I want to get rid of that so that it is just

<?xml version="1.0" encoding="UTF-8"?> ...

Please help. Thank you,

Song,

On Apr 28, 8:34 pm, Song C. [email protected] wrote:

I want to get rid of that so that it is just

<?xml version="1.0" encoding="UTF-8"?> ..

Since you want the xml declaration, I assume you want a valid XML
document. A valid XML document must have exactly one root element. You
cannot remove the root, because then if your hash had more than one
entry it would produce multiple roots and thus invalid XML.

You can change the name of the element, however:
hash.to_xml({:root => ‘steps’})

– Mark.

Thank you!!!
THis helps!!

Song,