home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libxml-grove-perl / examples / test-ids.pl < prev    next >
Encoding:
Text File  |  1999-10-23  |  739 b   |  33 lines

  1. #
  2. # $Id: test-ids.pl,v 1.1 1999/05/26 15:42:16 kmacleod Exp $
  3. #
  4.  
  5. # This example parses each doc on the command line and prints all of
  6. # the IDs found in the doc, with their Perl hash references
  7.  
  8. use XML::Parser;
  9. use XML::Parser::Grove;
  10. use XML::Grove;
  11. use XML::Grove::IDs;
  12.  
  13. my $doc;
  14.  
  15. my $id_maker = new XML::Grove::IDs;
  16.  
  17. foreach $doc (@ARGV) {
  18.     print "---- $doc ----\n";
  19.  
  20.     my $parser = XML::Parser->new(Style => 'grove');
  21.     $parser->parsefile ($doc);
  22.     my $grove = $parser->{Grove};
  23.  
  24.     my $ids = $grove->get_ids;
  25.     my $id;
  26.     foreach $id (sort keys %$ids) {
  27.     # prints the id and the hash reference to the element, not
  28.     # pretty but this is just a test.
  29.     # printing paths would be cool.
  30.     print "$id - $ids->{$id}\n";
  31.     }
  32. }
  33.