Rexml - get raw xml of elements and text

I'm aware that REXML's Element class can give me the elements or the text
(texts if there are many text elements between children elements). I want
them both, and I want them in order, straight XML. (I've got some bold and
italic tags there that are just for formatting)

Ammon Christiansen wrote:

I'm aware that REXML's Element class can give me the elements or the text
(texts if there are many text elements between children elements). I want
them both, and I want them in order, straight XML. (I've got some bold and
italic tags there that are just for formatting)

to_s ?

James

···

--

http://www.ruby-doc.org - Ruby Help & Documentation
Ruby Code & Style - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools

irb(main):001:0> require 'rexml/document'
=> true

irb(main):002:0> d = REXML::Document.new( '<xml>Hello <i>there</i> world</xml>' )
=> <UNDEFINED> ... </>

irb(main):003:0> d.root.each_child{ |n| p n }
"Hello "
<i> ... </>
" world"
=> ["Hello ", <i> ... </>, " world"]

···

On Dec 20, 2005, at 4:51 PM, Ammon Christiansen wrote:

I'm aware that REXML's Element class can give me the elements or the text
(texts if there are many text elements between children elements). I want
them both, and I want them in order, straight XML. (I've got some bold and
italic tags there that are just for formatting)