Forum: Ruby rexml - get raw xml of elements and text

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ammon C. (Guest)
on 2005-12-21 01:52
(Received via mailing list)
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)
James B. (Guest)
on 2005-12-21 02:01
(Received via mailing list)
Ammon C. 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
http://www.artima.com/rubycs/ - 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
Gavin K. (Guest)
on 2005-12-22 15:53
(Received via mailing list)
On Dec 20, 2005, at 4:51 PM, Ammon C. 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"]
This topic is locked and can not be replied to.