Class

XPathUtils

Extends:

Various XPath utility functions

Public Methods
find_image Find an image based on the src of the example
find_nearest_node_with_attribute Used when automatically looking up href attributes (for detail or next links) If the detail pattern did not extract a link, we first look up it’s children - and if we don’t find a link, traverse up
generate_XPath Generate XPath for the given node
generate_generalized_relative_XPath Generate a generalized XPath (i.e. without indices) of the node, relatively to the given relative_root.
generate_relative_XPath Generate an XPath of the node with indices, relatively to the given relative_root.
generate_relative_XPath_from_XPaths Generalre relative XPath from two XPaths: a parent one, (which points higher in the tree), and a child one. The result of the method is the relative XPath of the node pointed to by the second XPath to the node pointed to by the firs XPath.
lowest_common_ancestor Find the LCA (Lowest Common Ancestor) of two nodes
to_full_XPath
traverse_up_until_name Used to find the parent of a node with the given name - for example find the <form> node which is the parent of the <input /> node</form>
Private Methods
find_index Find the index of the child inside the parent For example:
first_child_node_with_attribute
first_parent_node_with_attribute
to_general_XPath
traverse_up
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.