[Nokogiri-talk] Spaces in predicate searches

pYuri.fy pyurify at gmail.com
Thu May 7 14:59:38 EDT 2009

When I perform a predicate search like:

if there is any spaces in the predicate, I get an error:
  Nokogiri::XML::XPath::SyntaxError: Invalid predicate

if I remove the spaces, the search runs without any problems.

Is this intentional?
require 'nokogiri'
require 'open-uri'

url = 'http://www.google.com/advanced_search?hl=en'
doc = Nokogiri.parse( open(url).read )

list = [
  'input[@name^="as_"]',  # okay
  'input[@name^= "as_"]', # error
  'input[@name ^="as_"]', # error
  'input[@name ^= "as_"]' # error

list.each do | css |
    doc.search( css )
    puts "#{css} - okay"
  rescue StandardError => e
    puts "#{css} - #{e.message}"

More information about the Nokogiri-talk mailing list