| Module | Hpricot::Container::Trav |
| In: |
lib/hpricot/modules.rb
lib/hpricot/traverse.rb |
Return all children of this node which can contain other nodes. This is a good way to get all HTML elements which aren‘t text, comment, doctype or processing instruction nodes.
each_hyperlink traverses hyperlinks such as HTML href attribute of A element.
It yields Hpricot::Text.
Note that each_hyperlink yields HTML href attribute of BASE element.
each_hyperlink_uri traverses hyperlinks such as HTML href attribute of A element.
It yields Hpricot::Text and URI for each hyperlink.
The URI objects are created with a base URI which is given by HTML BASE element or the argument ((|base_uri|)). each_hyperlink_uri doesn‘t yields href of the BASE element.
each_uri traverses hyperlinks such as HTML href attribute of A element.
It yields URI for each hyperlink.
The URI objects are created with a base URI which is given by HTML BASE element or the argument ((|base_uri|)).
filter rebuilds the tree without some components.
node.filter {|descendant_node| predicate } -> node
loc.filter {|descendant_loc| predicate } -> node
filter yields each node except top node. If given block returns false, corresponding node is dropped. If given block returns true, corresponding node is retained and inner nodes are examined.
filter returns an node. It doesn‘t return location object even if self is location object.
find_element searches an element which universal name is specified by the arguments. It returns nil if not found.
Find sibling elements which follow the current one. Like the other "sibling" methods, this weeds out text and comment nodes.
Insert nodes, an array of HTML elements or a single element, after the node ele, a child of the current node.
Insert nodes, an array of HTML elements or a single element, before the node ele, a child of the current node.
Returns the container node neighboring this node to the south: just below it. By "container" node, I mean: this method does not find text nodes or comments or cdata or any of that. See Hpricot::Traverse#next_node if you need to hunt out all kinds of nodes.
Find all preceding sibling elements. Like the other "sibling" methods, this weeds out text and comment nodes.
Returns the container node neighboring this node to the north: just above it. By "container" node, I mean: this method does not find text nodes or comments or cdata or any of that. See Hpricot::Traverse#previous_node if you need to hunt out all kinds of nodes.
Puts together an array of neighboring sibling elements based on their proximity to this element.
This method accepts ranges and sets of numbers.
ele.siblings_at(-3..-1, 1..3) # gets three elements before and three after ele.siblings_at(1, 5, 7) # gets three elements at offsets below the current element ele.siblings_at(0, 5..6) # the current element and two others
Like the other "sibling" methods, this doesn‘t find text and comment nodes. Use nodes_at to include those nodes.