Anybody tried to use XPath in REXML with a single quote, only to run into the fact that quote escaping in XPath is apparently not accounted for? If this were in the context on XSLT I'd be able to assign some annoying temp variable like $apos, but it's not, so I can't.
irb(main):001:0> require 'rexml/document'
=> true
irb(main):002:0> include REXML
=> Object
irb(main):003:0> xml = "<rss version='2.0'><channel><item><title>John's Doe</title></item></channel></rss>"
=> "<rss version='2.0'><channel><item><title>John's Doe</title></item></channel></rss>"
irb(main):004:0> xmldoc = Document.new xml
=> <UNDEFINED> ... </>
irb(main):005:0> XPath.first( xmldoc, "/rss/channel/item/title" ).to_s
=> "<title>John's Doe</title>"
irb(main):006:0> XPath.first( xmldoc, "/rss/channel/item/title[text()='John's Doe']" ).to_s
NoMethodError: undefined method `node_type' for "John":String
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:124:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:123:in `each'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:123:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:49:in `match'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:402:in `Predicate'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:346:in `Predicate'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:204:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:199:in `times'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:199:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:49:in `match'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:34:in `parse'
from /usr/local/lib/ruby/1.8/rexml/xpath.rb:28:in `first'
from (irb):6
irb(main):007:0> XPath.first( xmldoc, "/rss/channel/item/title[text()='John\'s Doe']" ).to_s
NoMethodError: undefined method `node_type' for "John":String
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:124:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:123:in `each'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:123:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:49:in `match'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:402:in `Predicate'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:346:in `Predicate'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:204:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:199:in `times'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:199:in `internal_parse'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:49:in `match'
from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:34:in `parse'
from /usr/local/lib/ruby/1.8/rexml/xpath.rb:28:in `first'
from (irb):7