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
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
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
the text
XML
REXML::XPath.each(doc, ‘//abstract/style/text()’) do |elm|
p elm
end
See also
http://www.w3schools.com/xpath/
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
Kind regards
robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs