11155
(-- --)
June 1, 2013, 7:33am
1
doc = Nokogiri::HTML::Document.parse(<<-eohtml)
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> ;
</head>
<body>
<form>
<input name="email" disabled="disabled" />
<input name="id" />
</form>
</body>
</html>
eohtml
p doc.css("input:disabled").count
# >> 2
# ~>
/home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in
`evaluate': xmlXPathCompOpEval: function disabled 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 -:69:in `<main>'
hassan
(Hassan Schroeder)
June 1, 2013, 2:54pm
2
What makes you think that's valid syntax?
11155
(-- --)
June 1, 2013, 3:04pm
3
Hassan Schroeder wrote in post #1110918:
hassan
(Hassan Schroeder)
June 1, 2013, 3:29pm
4
Uh, that's nice. But your question is about Nokogiri, not jQuery.
11155
(-- --)
June 1, 2013, 3:35pm
5
Hassan Schroeder wrote in post #1110922:
hassan
(Hassan Schroeder)
June 1, 2013, 3:53pm
6
Where in the Nokogiri docs does it say that? Where in the docs is
an example of the syntax you are trying to use?
11155
(-- --)
June 1, 2013, 4:17pm
7
Hassan Schroeder wrote in post #1110928:
Where in the Nokogiri docs does it say that? Where in the docs is
an example of the syntax you are trying to use?
see below:
require "nokogiri"
doc = Nokogiri::HTML::Document.parse(<<-eohtml)
<html>
<head>
<style>
div { float:left; }
span { color:blue; }
</style>
</head>
<body>
<div>
<p>div1 p1</p>
<p>div1 p2</p>
<p>div1 p3</p>
<p>div1 p4</p>
</div>
<div>
<p>div2 p1</p>
<p>div2 p2</p>
<p>div2 p3</p>
<p>div2 p4</p>
</div>
</body>
</html>
eohtml
p doc.css("div p:eq(2)").map { |e| e.text }
# >> ["div1 p2", "div2 p2"]
hassan
(Hassan Schroeder)
June 1, 2013, 4:33pm
8
Where in the Nokogiri docs does it say that? Where in the docs is
an example of the syntax you are trying to use?
see below:
Uh, as I said -- in the docs?
p doc.css("div p:eq(2)")
And in this case, what do you think 'eq' is ?
11155
(-- --)
June 1, 2013, 4:47pm
9
Hassan Schroeder wrote in post #1110932:
hassan
(Hassan Schroeder)
June 1, 2013, 5:15pm
10
Uh, sure. Whatever you want to believe. Good luck!
11155
(-- --)
June 1, 2013, 5:28pm
11
Hassan Schroeder wrote in post #1110937:
So here is something I don't quite understand. According to [1],
"input:disabled" is a quite valid CSS selector.
Given this[2]:
<html><body>
<style>input:disabled {background: #0F0 ; color: #F00 ;}</style>
<input type="text" id="greenjunk" name="greenjunk" value="nada" disabled />
<input type="text" id="name" name="name" value="Joe" />
<input type="submit" id="submit" name="submit" value="submit" />
</body></html>
Why wouldn't doc.css("input:disabled") also work? Clearly it doesn't,
but I don't know what it *should* be. (Noting that xpath would be quite
different, of course.)
[1] :disabled - CSS: Cascading Style Sheets | MDN
[2] see this ugly thing at https://dl.dropboxusercontent.com/u/571329/Examples/greenjunk.html
11155
(-- --)
June 1, 2013, 8:01pm
13