[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Problems with text() and REXML

Kenneth McDonald

1/20/2009 5:47:00 PM

I'm finding that in REXML, the XPath selector "//abstract//style"
correctly selects nodes in the tree, but "//abstract//style//text()"
does not then extract the text from those nodes. Is this a known
problem with XPath in Rexml?

Thanks,
Ken


1 Answer

Robert Klemme

1/20/2009 10:28:00 PM

0

On 20.01.2009 18:46, Kenneth McDonald wrote:
> I'm finding that in REXML, the XPath selector "//abstract//style"
> correctly selects nodes in the tree, but "//abstract//style//text()"
> does not then extract the text from those nodes. Is this a known
> problem with XPath in Rexml?

You're abusing "//". This works for me

#!/bin/env ruby

require 'rexml/document'

doc = REXML::Document.new <<XML
<root>
<abstract>
<style>
the text
</style>
</abstract>
</root>
XML

REXML::XPath.each(doc, '//abstract/style/text()') do |elm|
p elm
end

See also
http://www.w3schools....
http://www.zvon.org/xxl/XPathTutorial/General/exa...

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end