XML::Parser::Lite::Tree::XPath - XPath access to XML::Parser::Lite::Tree structures
use XML::Parser::Lite::Tree; use XML::Parser::Lite::Tree::XPath; my $parser = new XML::Parser::Lite::Tree(process_ns => 1); my $tree = $parser->parse($xml); my $xpath = new XML::Parser::Lite::Tree::XPath($tree); my $nodes = $xpath->select_nodes('/aaa'); my $nodes = $xpath->select_nodes('/*/*/parent::*'); my $nodes = $xpath->select_nodes('//ccc[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]');
This pure-Perl implementation of XPath is a complement to XML::Parser::Lite::Tree, a pure-Perl XML tree parser and builder. It aims to implement 100% of the W3C XPath specification.
new( $tree )
The constructor returns a new XPath parser for the given tree.
query( $path )
Returns a XML::Parser::Lite::Tree::XPath::Result object containing the result of the query.
select_nodes( $path )
A convinience function around query() which returns 0 unless the result is a nodeset, else returns the value of the nodeset.
query()
Copyright (C) 2004-2008, Cal Henderson <cal@iamcal.com>
XML::Parser::Lite::Tree
To install XML::Parser::Lite::Tree::XPath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Parser::Lite::Tree::XPath
CPAN shell
perl -MCPAN -e shell install XML::Parser::Lite::Tree::XPath
For more information on module installation, please visit the detailed CPAN module installation guide.