Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XPath cannot return string values #208

Closed
Phrogz opened this issue Jan 20, 2010 · 4 comments
Closed

XPath cannot return string values #208

Phrogz opened this issue Jan 20, 2010 · 4 comments

Comments

@Phrogz
Copy link

Phrogz commented Jan 20, 2010

require 'nokogiri'
xpath = "concat('a','b')"
d = Nokogiri::HTML("")
p d.at_xpath(xpath), d.xpath(xpath)
#=> nil
#=> []

Compare this with the following string pasted into the address bar of Safari, Chrome, Firefox, or Opera:
javascript:alert( (new XPathEvaluator).evaluate( "concat('a','b')", document.documentElement ).stringValue );

Or compare to the result from the REXML implementation:

require 'rexml/document'
d = REXML::Document.new("")
p REXML::XPath.first(d, "concat('a','b')")
#=> "ab"
@tenderlove
Copy link
Member

:'(

@Phrogz
Copy link
Author

Phrogz commented Jan 20, 2010

Now now, don't cry. It's not like there aren't plenty of workarounds in consumer code. :)

@tenderlove
Copy link
Member

xpath methods can return things other than nodesets, you know, cause its fast. closed by 45c6d1d

@Phrogz
Copy link
Author

Phrogz commented Jan 20, 2010

Whoa, that was fast. Nice!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants