Nokogiri#css not working with ":checked" selector.

328 views
Skip to first unread message

Arup Rakshit

unread,
Jun 1, 2013, 2:54:02 AM6/1/13
to nokogi...@googlegroups.com
Hi,

I was testing the css rule ":checked", but it is throwing error as below:

require "nokogiri"

#######################################################
#####             :checkbox Selector              #####
#######################################################
doc =  Nokogiri::HTML::Document.parse(<<-eohtml)
<html>
<head>
<style>
div { color:red; }
</style>
</head>
<body>
<form>
<p>
<input type="checkbox" name="newsletter" value="Hourly" checked="checked">
<input type="checkbox" name="newsletter" value="Daily">
<input type="checkbox" name="newsletter" value="Weekly">
<input type="checkbox" name="newsletter" value="Monthly" checked>
<input type="checkbox" name="newsletter" value="Yearly">
</p>
</form>
<div></div>
</body>
</html>
eohtml

p doc.css("input:checked").count
# ~> /home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in `evaluate': xmlXPathCompOpEval: function checked not found (RuntimeError)
# ~>     from /home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in `block in xpath'
# ~>     from /home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:150:in `map'
# ~>     from /home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:150:in `xpath'
# ~>     from /home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:214:in `css'
# ~>     from -:28:in `<main>'


Can any one help me here for the same?

Thanks,
Arup






Mike Dalessio

unread,
Jun 2, 2013, 1:13:06 PM6/2/13
to nokogiri-talk
Hi,

Thanks for asking this question.


Currently Nokogiri doesn't implement a variety of CSS pseudo-selectors. This is on the roadmap for Nokogiri 2.0, which you can view at https://github.com/sparklemotion/nokogiri/blob/master/ROADMAP.md

 

Thanks,
Arup






--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
To post to this group, send email to nokogi...@googlegroups.com.
Visit this group at http://groups.google.com/group/nokogiri-talk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages