NAME
XML::Parser::Lite::Tree::XPath - XPath access to XML::Parser::Lite::Tree trees
SYNOPSIS
use XML::Parser::Lite::Tree;
use XML::Parser::Lite::Tree::XPath;
my $xpath = new XML::Parser::Lite::Tree::XPath($tree);
my @nodes = $xpath->select_nodes('/photoset/photos');
DESCRIPTION
This module offers limited XPath functionality for XML::Parser::Lite::Tree
objects. The following portions of XPath are supported:
/foo/bar/baz exact node names
/foo/*/* wildcard node names
/foo/text() 'text()' function (nodes with type=text)
/foo/nodes() same as '*'
/foo[1] numeric subrules
/foo[last()] 'last()' subrule
/foo[@bar] attribute existance
/foo[@bar=2] attribute testing (with ops =, !=, >, <, >=, <=)
//foo self-or-descendant searches
Subrules can be chained together and are processed left to right, eg:
/foo[3][@bar][@baz="quux"]
/foo[last()]/bar[@bax>10]
Things which aren't supported but might be later:
/foo[@bar and @baz] just use /foo[@bar][@baz]
/foo[position()<6] 'position()' isn't supported and neither are non-attribute expressions
Things which aren't supported:
/child::foo[position()=1] axis tests
../foo/bar relative paths
/foo[@foo<1 or @bar>3] boolean operators ('and' can be made into chained subrules)
METHODS
new($tree)
-
Returns an
XML::Parser::Lite::Tree::XPath
object for the given tree. set_tree($tree)
-
Sets the tree for the object.
select_nodes($xpath)
-
Returns an array of nodes for the gtiven XPath.
AUTHOR
Copyright (C) 2004, Cal Henderson, <cal@iamcal.com>
SEE ALSO
XML::Parser::Lite XML::Parser::Lite::Tree http://www.w3.org/TR/xpath