# help
Hi, everyone,
I have a hash obj and when converted to xml using to_xml the <hash></hash> tag appears like the following
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<step1>
...
</hash>
I want to get rid of that <hash> so that it is just
<?xml version="1.0" encoding="UTF-8"?>
<step1>
...
</step1>
Please help. Thank you,
Song,
···
_________________________________________________________________
Windows Live™ SkyDrive™: Get 25 GB of free online storage.
http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_042009
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.
···
On Apr 28, 8:34 pm, Song Choe <cho...@hotmail.com> wrote:
# help
Hi, everyone,
I have a hash obj and when converted to xml using to_xml the <hash></hash> tag appears like the following
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<step1>
..
</hash>
I want to get rid of that <hash> so that it is just
<?xml version="1.0" encoding="UTF-8"?>
<step1>
..
</step1>
Thank you!!!
THis helps!!
Song,
···
Date: Wed, 29 Apr 2009 10:30:05 +0900
From: mark@thomaszone.com
Subject: Re: How to eliminate hash tag when to_xml is used.
To: ruby-talk@ruby-lang.org
On Apr 28, 8:34 pm, Song Choe <cho...@hotmail.com> wrote:
> # help
>
> Hi, everyone,
>
> I have a hash obj and when converted to xml using to_xml the <hash></hash> tag appears like the following
>
> <?xml version="1.0" encoding="UTF-8"?>
> <hash>
> <step1>
> ..
> </hash>
>
> I want to get rid of that <hash> so that it is just
> <?xml version="1.0" encoding="UTF-8"?>
> <step1>
> ..
> </step1>
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.
_________________________________________________________________
Windows Live™ Hotmail®:…more than just e-mail.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_more_042009