From: Gavin Kistner Date: 2005-09-15T23:19:23+09:00 Subject: Re: REXML feature request: XPath.match.text & better text documentation On Sep 15, 2005, at 3:56 AM, Dan Kohn wrote: > Sean, et al, thanks for a great piece of software in REXML. I would > appreciate if you would consider adding the text and texts method to > XPath and Elements. Does this help you? require 'rexml/document' include REXML d = Document.new < Raw text Raw text2 AA Nested TextZZ ENDXML p XPath.match( d, '//foo//text()' ).collect{ |textnode| textnode.value } #=> ["Raw text", "Raw text2", "AA", "Nested Text", "ZZ"] class REXML::Element def inner_text self.each_element( './/text()' ){}.join( '' ) end end p XPath.match( d, '//foo' ).collect{ |foo| foo.inner_text } #=> ["Raw text", "Raw text2", "AA Nested TextZZ"]