Hi,

From: "Matthew, Graeme" <Graeme.Matthew / mercer.com>
Subject: REXML
Date: Wed, 30 Oct 2002 12:02:02 +0900
Message-ID: <AFB901DF1A6CD411A3AD00D0B781F8E5049CA112 / wmelntms01.au.wmmercer.com>

> Here is the request xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <request type="chart" value="PSK">
> <criteria>
> <market>1</market>
> <benchmark>2</benchmark>
> <manager>1,2,3,4,5</manager>
> <from>31/12/2001</from>
> <to>31/12/2002</to>
> </criteria>
> </request>
> 
> the above is assigned to the xmlSent variable
> the criteria is where I cannot get it to work
> 
> what I want to do is get all the elements for <criteria> and add them into
> the hash
> for example:
> 
> object['criteria']['market'] = '1'
> object['criteria']['benchmark'] = '1'
> object['criteria']['manager'] = '1,2,3,4,5'

What about this?

rq = (Document.new xmlSent).root
if rq.elements.size == 1 then     
  object['type'] = rq.attributes['type']
  object['value'] = rq.attributes['value']
  object['criteria'] = {}
  rq.elements['criteria'].each_element do |element|
    object['criteria'][element.name] = element.text
  end
end

Regards,
======================
Kouhei Sutou
kou / cneti.net