XML::TreePP::XMLPath

Similar to XPath, defines a path as an accessor to nodes of an XML::TreePP parsed XML Document
Download

XML::TreePP::XMLPath Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Russell E Glaue
  • Publisher web site:
  • http://search.cpan.org/~rglaue/

XML::TreePP::XMLPath Tags


XML::TreePP::XMLPath Description

Similar to XPath, defines a path as an accessor to nodes of an XML::TreePP parsed XML Document XML::TreePP::XMLPath is a pure Perl module to compliment the pure PERL XML::TreePP module. XMLPath may be similar to XPath, and it does attempt to conform to the XPath standard when possible, but it is far from being fully XPath compliant.Its purpose is to implement an XPath-like accessor methodology to nodes in a XML::TreePP parsed XML Document. In contrast, XPath is an accessor methodology to nodes in an unparsed (or raw) XML Document.The advantage of using XML::TreePP::XMLPath over any other PERL implementation of XPath is that XML::TreePP::XMLPath is an accessor to XML::TreePP parsed XML Documents. If you are already using XML::TreePP to parse XML, you can use XML::TreePP::XMLPath to access nodes inside that parsed XML Document without having to convert it into a raw XML Document.As an additional side-benefit, any PERL HASH/ARRY reference data structure can be accessible via the XPath accessor method provided by this module. It does not have to a parsed XML structure. The last example in the SYNOPSIS illustrates this.SYNOPSIS use XML::TreePP; use XML::TreePP::XMLPath; my $tpp = XML::TreePP->new(); my $tppx = XML::TreePP::XMLPath->new(); my $tree = { rss => { channel => { item => } } }; my $xml = $tpp->write( $tree );Get a subtree of the XMLTree: my $xmlsub = $tppx->filterXMLDoc( $tree , q{rss/channel/item} ); print $xmlsub->{'link'};Iterate through all attributes and Elements of each XML element: my $xmlsub = $tppx->filterXMLDoc( $tree , q{rss/channel/item} ); my $h_attr = $tppx->getAttributes( $xmlsub ); my $h_elem = $tppx->getElements( $xmlsub ); foreach $attrHash ( @{ $h_attr } ) { while my ( $attrKey, $attrVal ) = each ( %{$attrHash} ) { ... } } foreach $elemHash ( @{ $h_elem } ) { while my ( $elemName, $elemVal ) = each ( %{$elemHash} ) { ... } }EXAMPLE for using XML::TreePP::XMLPath to access a non-XML compliant tree of PERL referenced data. use XML::TreePP::XMLPath; my $tppx = new XML::TreePP::XMLPath; my $hashtree = { config => { nodes => { "10.0.10.5" => { options => , alerts => { email => 'someone@nowhere.org' } } } } }; print $tppx->filterXMLDoc($hashtree, '/config/nodes/10.0.10.5/alerts/email'); print " "; print $tppx->filterXMLDoc($hashtree, '/config/nodes/10.0.10.5/options'); print " ";Result someone@nowhere.org option2 Requirements: · Perl


XML::TreePP::XMLPath Related Software