From: Nat Pryce Date: 2002-04-05T20:38:53+09:00 Subject: A Quick and Dirty Solution (was Re: REXML queries) On Fri, Apr 05, 2002 at 01:08:02AM +0900, Nat Pryce wrote: > ...is there an easy way to copy an entire tree of nodes? I'd like to > build a new document by copying subtrees from another document. The clone > method copies the name of the element, but *not* the attributes or children. Here's a quick-and-dirty solution. Inelegant, but it works. Just add this code to your program, and the Element class has a deep_clone method that copies all children and attributes. require 'rexml/document' module REXML class Element def deep_clone() Element.new( SourceFactory.create_from( self.to_s ) ) end end end ________________________________ Dr. Nathaniel Pryce B13media Ltd. 40-41 Whiskin St, London, EC1R 0BP, UK http://www.b13media.com