Forum: Ruby xmlsimple: prevent folding multiple elements into array?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
563e3eea8bb7750b2d555085a547f97a?d=identicon&s=25 slothbear (Guest)
on 2007-07-17 03:45
(Received via mailing list)
I have some xml that represents a somewhat weirdly formed hash.
XmlSimple is eating some of my structure.


XmlSimple.xml_in(xml, {'ForceArray'=>false})

{"map"=> {
    "time"=>["daily", "monthly"],
     "key"=>["state", "rate", "duration"],

With the arrays folded that way, there's no way for me to tell that
the value of "state" is "open".  I don't really care about the
"datatypes".  I'm aiming at a single level hash something like this:

{"map"=> {
     "state" => "open,
     "rate" => "daily",
     "duration" => "monthly"

I can't really change the odd incoming XML, but I'm happy to process
any Ruby data structure that hasn't lost some of my order/structure.
All of the options around folding appear to affect only attributes,
but I have only elements.
80fa6dadfaeddd631995b31b66a41b8e?d=identicon&s=25 Weston Campbell (ruby-panda)
on 2007-07-17 04:10
Man, wish I could help you there. The problem is that the only languages
that I have been able to work with XML in are ActionScript and Java...
and Ruby really doesn't look like either, not to mention I can't even
seem to find some decent tutorials that explain it...

Oh well, sorry for taking up space on this thread. But perchance, you
may want to investigate the REXML library that comes with Ruby. It's
just an alternative to XMLSimple.
563e3eea8bb7750b2d555085a547f97a?d=identicon&s=25 slothbear (Guest)
on 2007-07-20 02:36
(Received via mailing list)
Thanks for the thoughts!  I figured I would have to move to REXML
eventually, and I guess it's time.  thanks again.
This topic is locked and can not be replied to.