From: "Matthew, Graeme" Date: 2002-10-30T12:02:02+09:00 Subject: REXML Hi all, please can someone help , I am almost at the point of losing it ! :-) I am writing a drb application that will recieve an XML 'envelope' that identifies a request, the object type to instantiate and the criteria to apply to the objects constructor. I am having trouble trying to traverse and extract the xml data elements Please could someone help Here is the request xml 1 2 1,2,3,4,5 31/12/2001 31/12/2002 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 and add them into the hash for example: object['criteria']['market'] = '1' object['criteria']['benchmark'] = '1' object['criteria']['manager'] = '1,2,3,4,5' the elements within are dynamic so I dont want to hardcode it rq = (Document.new xmlSent).root #at this point in time we handle a single xml request #if the entity has 1 'record' then process if rq.elements.size == 1 then object['type'] = rq.elements["//request"].attributes['type'] object['value'] = rq.elements["//request"].attributes['value'] object['criteria'] = [] rq.elements.each_element_with_text("//request[1]/criteria") { |element| #### from here on I have tried everything, the problem is how to loop criteria and add to hash including the elements tag name ie = object['criteria']['market'] Any help would be great !!! Graeme Matthew Analyst Programmer Mercer Investment Consulting Level 29, 101 Collins Street, Melbourne, VIC, 3001, Australia Tel - 61 3 9245 5352 Fax - 61 3 9245 5330 visit http://www.merceric.com __ ********************************************** This e-mail and any attachments may be confidential or legally privileged. If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein. Please inform us of the erroneous delivery by return e-mail. Thank you for your cooperation. ********************************************** ec03/04