sera / fhwang.net (Francis Hwang) wrote in message news:<7b561b93.0402041638.4ede5c53 / posting.google.com>... > Say I have a string that represents an XML element that I want to > embed into a REXML::Element, how would I do this? > > For example, if I have: > > xhtml_elt = REXML::Element.new( 'xhtml' ) > xhtml_string = "<p>foo <strong>bar</strong></p>" > > Is there a way I could get to: > > puts xhtml_elt.to_s > => <xhtml><p>foo <strong>bar</strong></p></xhtml> > > Francis Oh, for Pete's sake. All I had to do was use REXML::Document#root. irb(main):001:0> require 'rexml/document' => true irb(main):002:0> string = "<p>foo <strong>bar</strong></p>" => "<p>foo <strong>bar</strong></p>" irb(main):003:0> REXML::Document.new( string ).root.to_s => "<p>foo <strong>bar</strong></p>"