From: Matt Gushee Date: 2002-09-12T01:45:01+09:00 Subject: Re: using REXML for XML document creation On Thu, Sep 12, 2002 at 12:59:42AM +0900, Ian Macdonald wrote: > > As an REXML beginner, I'm having trouble figuring out how to nest one > element within another. Basically, I need something like this: > > > > > > > > Right now, I can create each element sequentially, but I'm having a > hard time getting all the elements inside the > element. You're probably expecting it to be harder than it is. If you've ever worked with the DOM, building a document with REXML is similar but simpler. For example: require 'rexml/document' doc = REXML::Document.new elt = doc.add_element("ADDRESSBOOK") elt = elt.add_element("CONTACTS") elt = elt.add_element("CONTACT") elt.add_attribute("FileAs","Macdonald, Ian") Hope this helps. -- Matt Gushee Englewood, Colorado, USA mgushee@havenrock.com http://www.havenrock.com/