You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if its supposed to work or not (I'm rather new to ruby) but when calling .keys on the tag it throws an error:
$ ruby -r nokogiri -e 'Nokogiri::HTML("<html></html>").traverse { |n| puts n.node_name ; puts n.keys };'
html
/opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node.rb:397:in `keys': undefined local variable or method `attribute_nodes' for #<Nokogiri::XML::DTD:0x00000000976888> (NameError)
from -e:1:in `block in <main>'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node.rb:595:in `call'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node.rb:595:in `traverse'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node.rb:594:in `block in traverse'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node_set.rb:239:in `block in each'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node_set.rb:238:in `upto'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node_set.rb:238:in `each'
from /opt/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/nokogiri/xml/node.rb:594:in `traverse'
from -e:1:in `<main>'
Hi. I think what you probably want to do is to start from the root node of the document:
Nokogiri::HTML("<html></html>").root.traverse ...
The DTD doesn't have attributes in the sense that a HTML/XML element does. The bug here is that Nokogiri::XML::DTD has a keys method. That will be removed.
Hi,
I don't know if its supposed to work or not (I'm rather new to ruby) but when calling .keys on the tag it throws an error:
The error says that the node is of type Nokogiri::XML::DTD , so I looked at http://nokogiri.org/Nokogiri/XML/DTD.html and followed the link to http://nokogiri.org/Nokogiri/XML/Node.html where documents there's a
keys
method.But I also realized that calling
.attributes
on the HTML node returns nil.The text was updated successfully, but these errors were encountered: