[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: rexml - get raw xml of elements and text

Gavin Kistner

12/22/2005 1:53:00 PM

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)

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"]