home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libxml-parser-perl / examples / xmlcomments < prev    next >
Encoding:
Text File  |  2004-11-24  |  687 b   |  45 lines

  1. #!/usr/bin/perl -w
  2. #
  3. # $Revision: 1.1.1.1 $
  4. #
  5. # $Date: 2003/07/27 11:07:11 $
  6.  
  7. use XML::Parser;
  8.  
  9. my $file = shift;
  10.  
  11. die "Can't find file \"$file\""
  12.   unless -f $file;
  13.     
  14. my $count = 0;
  15.  
  16. my $parser = new XML::Parser(ErrorContext => 2,
  17.                  ParseParamEnt => 0
  18.                 );
  19.  
  20. $parser->setHandlers(Comment => \&comments);
  21.  
  22. $parser->parsefile($file);
  23.  
  24. print "Found $count comments.\n";
  25.  
  26. ################
  27. ## End of main
  28. ################
  29.  
  30. sub comments
  31. {
  32.     my ($p, $data) = @_;
  33.  
  34.     my $line = $p->current_line;
  35.     $data =~ s/\n/\n\t/g;
  36.     print "$line:\t<!--$data-->\n";
  37.     $count++;
  38.  
  39. }  # End comments
  40.  
  41. # Tell Emacs that this is really a perl script
  42. # Local Variables:
  43. # mode:perl
  44. # End:
  45.