#!/usr/bin/perl -w use strict; use XML::Parser; my %tags; my $p = XML::Parser->new(Handlers => { Start => sub {$tags{$_[1]}++; }, }, ) or die "cannot create parser :: $!"; foreach my $file (@ARGV) { eval { $p->parsefile($file); }; die $@ if $@; } print "The keys are\n"; print map "$_\n", sort keys %tags; print "There are ", scalar(keys %tags), " tags in the files\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Count number of unique tags in XML files
by mirod (Canon) on Mar 26, 2004 at 08:24 UTC | |
|
Re: Count number of unique tags in XML files
by hawtin (Prior) on Mar 26, 2004 at 08:32 UTC | |
by mirod (Canon) on Apr 09, 2004 at 17:15 UTC |