class HTML::Selector
def select(root)
puts "Found text field with name #{match.attributes['name']}"
matches.each do |match|
matches = selector.select(element)
selector = HTML::Selector.new "input[type=text]"
For example:
itself.
The root node may be any element in the document, or the document
Returns an empty array if no match is found.
with one node and traversing through all children depth-first.
Selects and returns an array with all matching elements, beginning
select(root) => array
:call-seq:
def select(root) matches = [] stack = [root] while node = stack.pop if node.tag? && subset = match(node, false) subset.each do |match| matches << match unless matches.any? { |item| item.equal?(match) } end elsif children = node.children stack.concat children.reverse end end matches end