From: Phrogz Date: 2006-08-24T05:45:15+09:00 Subject: Re: (RE)XML question rubyhacker@gmail.com wrote: > Contrived example below in case it helps. input = <

Hi, there.

some more text

That's all.

ENDHTML require 'rexml/document' doc = REXML::Document.new( input ) doc.root.each_element( '//foo' ){ |e| new_para = REXML::Element.new( 'p' ) new_para.text = "I found a foo tag enclosing '#{e.text}' with bar and bam values of '#{e.attributes['bar']}' and '#{e.attributes['bam']}'..." e.parent.replace_child( e, new_para ) } puts doc #=> #=> #=>

Hi, there.

#=>

I found a foo tag enclosing 'some more text' with bar and bam values of 'this' and 'that'...

#=>

That's all.

#=> #=>