Andrea Guzzo > XML-TinyXML > XML::TinyXML::Selector::XPath

Download:
XML-TinyXML-0.34.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.34   Source  

NAME ^

XML::TinyXML::Selector::XPath - XPath-compliant selector for XML::TinyXML

SYNOPSIS ^

  use XML::TinyXML;

  # first obtain an xml context:
  $xml = XML::TinyXML->new("rootnode", param => "somevalue", attrs => { attr1 => v1, attr2 => v2 });

  $selector = XML::TinyXML::Selector->new($xml, "XPath");

  #####
  Assuming the following xml data :
  <?xml version="1.0"?>
  <xml>
    <hello>world</hello>
    <foo>
      <![CDATA[ this should unescape <&; etc... :) ]]>
    </foo>
    <parent>
      <child1/>
      <child2/>
      <child3/>
    </parent>
    <parent>
      <blah>SECOND</blah>
    </parent>
  </xml>
  #####

  @res = $selector->select('//parent');
  @res = $selector->select('//child*');
  @res = $selector->select('/parent[2]/blah/..');
  @res = $selector->select('//blah/..');
  @res = $selector->select('//parent[1]/..');
  @res = $selector->select('//parent[1]/.');
  @res = $selector->select('//blah/.');

  # or using the unabbreviated syntax:

  @res = $selector->select('/descendant-or-self::node()/child::parent');
  @res = $selector->select('/descendant-or-self::node()/child::child*');
  @res = $selector->select('/child::parent[2]/child::blah/parent::node()');
  @res = $selector->select('/descendant-or-self::node()/child::blah/parent::node()');
  @res = $selector->select('/descendant-or-self::node()/child::parent[1]/parent::node()');
  @res = $selector->select('/descendant-or-self::node()/child::parent[1]/self::node()');
  @res = $selector->select('/descendant-or-self::node()/child::blah/self::node()');


  # refer to XPath documentation for further examples and details on the supported syntax:
  # ( http://www.w3.org/TR/xpath )

DESCRIPTION ^

XPath-compliant selector for XML::TinyXML

INSTANCE VARIABLES ^

METHODS ^

SEE ALSO ^

XML::TinyXML XML::TinyXML::Node XML::TinyXML::Selector

AUTHOR ^

xant, <xant@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2009-2010 by xant

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: