Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion parse an xml snippet to a hash

View Parsed - Show only message text

Received: by 10.223.106.129 with SMTP id x1mr148773fao.6.1246530222194;
        Thu, 02 Jul 2009 03:23:42 -0700 (PDT)
Return-Path: <biot...@gmail.com>
Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.157])
        by gmr-mx.google.com with ESMTP id 16si240798bwz.4.2009.07.02.03.23.41;
        Thu, 02 Jul 2009 03:23:41 -0700 (PDT)
Received-SPF: pass (google.com: domain of biot...@gmail.com designates 72.14.220.157 as permitted sender) client-ip=72.14.220.157;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of biot...@gmail.com designates 72.14.220.157 as permitted sender) smtp.mail=biot...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by fg-out-1718.google.com with SMTP id e21so459960fga.21
        for <nwrug-members@googlegroups.com>; Thu, 02 Jul 2009 03:23:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:from:date:message-id
         :subject:to:content-type;
        bh=lPTcmntI37igUAkzkM/MwqGlJD5Mvz5cC08rBT9wdKk=;
        b=J8CZu+wVd+ytukqMGIevOOehi9tTOjyKWQPzVIF1nM+PO8+b5AZUHT/fAYFsjm55zV
         i22vK/iJCV5Xltov+gO3v+CCbMcbN0NXi5j7yWRcy3l1NtJmFTSzxAb5eZ8zyFz9HSDW
         B8AS2NuWjdrrsC9UbJeErIfdC1a0G2+q0ClyU=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:from:date:message-id:subject:to:content-type;
        b=An1SZCobS7peXEbLmQSr1KO7lRTtcHyAcSd7Jh31mA9FjHdGCu55xWGykavzDzK0lC
         zRVdF9ZUL6Gt5ZNYZ2pNo2FfweZATXsaX9phTeWc7QL+pOHwXugNvKI6VsYM/EWh4Jwy
         G+EQ4TBhhb2rimHLtCE/6JPKnCtGtl533jpWk=
MIME-Version: 1.0
Received: by 10.86.62.8 with SMTP id k8mr264194fga.52.1246530221076; Thu, 02 
	Jul 2009 03:23:41 -0700 (PDT)
From: doug livesey <biot...@gmail.com>
Date: Thu, 2 Jul 2009 11:23:21 +0100
Message-ID: <50873a360907020323x445baa8l767217625e205125@mail.gmail.com>
Subject: parse an xml snippet to a hash
To: nwrug-members@googlegroups.com
Content-Type: multipart/alternative; boundary=000e0cd2465207735e046db66fab

--000e0cd2465207735e046db66fab
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi -- I have a custom ActiveResource action that returns the following xml:

"<result>\n  <successes>\n    <1>a082000000HqJzUAAV</1>\n
<2>a082000000HqJzsAAF</2>\n    <3>a082000000HqJzVAAV</3>\n  </successes>\n
<failures>\n  </failures>\n</result>\n"

Is there a quick & easy way to turn this into the following hash?

{ "result" { "successes" => { "1" => "a082000000HqJzUAAV", "2" =>
"a082000000HqJzsAAF", "3" => "a082000000HqJzVAAV" }, "failures" => {} }

Or should I go off & learn hpricot like I've been meaning to for ~3 years?
Cheers,
   Doug.

--000e0cd2465207735e046db66fab
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi -- I have a custom ActiveResource action that returns the following xml:=
<br><br>&quot;&lt;result&gt;\n=A0 &lt;successes&gt;\n=A0=A0=A0 &lt;1&gt;a08=
2000000HqJzUAAV&lt;/1&gt;\n=A0=A0=A0 &lt;2&gt;a082000000HqJzsAAF&lt;/2&gt;\=
n=A0=A0=A0 &lt;3&gt;a082000000HqJzVAAV&lt;/3&gt;\n=A0 &lt;/successes&gt;\n=
=A0 &lt;failures&gt;\n=A0 &lt;/failures&gt;\n&lt;/result&gt;\n&quot;<br>

<br>Is there a quick &amp; easy way to turn this into the following hash?<b=
r><br>{ &quot;result&quot; { &quot;successes&quot; =3D&gt; { &quot;1&quot; =
=3D&gt; &quot;a082000000HqJzUAAV&quot;, &quot;2&quot; =3D&gt; &quot;a082000=
000HqJzsAAF&quot;, &quot;3&quot; =3D&gt; &quot;a082000000HqJzVAAV&quot; }, =
&quot;failures&quot; =3D&gt; {} }<br>

<br>Or should I go off &amp; learn hpricot like I&#39;ve been meaning to fo=
r ~3 years?<br>Cheers,<br>=A0=A0 Doug.<br>

--000e0cd2465207735e046db66fab--

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google