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"]
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a10964d78e1f826d34f1080c036c98d2%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment