I had a problem with Nokogiri working correctly. I am using version 1.4.4 with Ruby 1.9.2.
I have libxml2 libxslt installed and updated. When I run the Ruby script with XML, it works fine.
require 'nokogiri' doc = Nokogiri::XML(File.open("test.xml")) doc = doc.css("name").each do |node| puts node.text end
Enter CL, run ruby test.rb , return
Name 1 Name 2 Name 3
And the crowd goes crazy. I am setting up a few things, doing a few code settings ...
require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML(open("http://domain.tld")) doc = doc.css("p").each do |node| puts node.text end
Back to CL, ruby test.rb , returns ... nothing! Just a new, empty line.
Is there a reason why it will work with an XML file, but not with HTML?
source share