[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

how to convert xml to text in ruby

Shweta Kadam

3/5/2008 5:27:00 AM

how to convert xml to text in ruby
1 Answer

Phlip

3/5/2008 5:40:00 AM

0

> how to convert xml to text in ruby

Hpricot, Libxml, or REXML?

Here's 'inner_text' in REXML:

def inner_text(interstitial = '')
return self.each_element( './/text()' ){}.join(interstitial)
end

It strips out all tags & attributes, and returns only the textual contents
between them.

( via http://assertxpath.rubyforge.org/classes/REXML/Element.ht... )

Replace 'self' with a REXML node to get cooking...

--
Phlip