On Mar 19, 8:04 am, "Phrogz" <g... / refinery.com> wrote:
> On Mar 19, 5:38 am, Paul Willis <i... / paulwillis.com> wrote:
>
> > root.elements["NewsItem/NewsComponent/NewsComponent[1]/NewsComponent/Conten tItem/DataContent/nitf/body/body.head/hedline/hl1"]
>
> > Gives me...
>
> > <hl1>Blueprint to cut emissions unveiled</hl1>
>
> > Is there an easy way (ie something in REXML) to pull just the text
> > without the containers <hl1> and </hl1>.
>
> require 'rexml/document'
> doc = REXML::Document.new("<root><kid>hello world</kid></root>")
> p REXML::XPath.first( doc, '/root/kid/text()' )
> #=> "hello world"

Also, depending on your needs:

  include REXML
  doc = Document.new("<root><kid>hello</kid><kid>world</kid></root>")
  p XPath.match( doc, '/root/kid/text()' )
  #=> ["hello", "world"]