##
my $file ='products.xml';
my $parser = new XML::Parser(Style=>'Stream');
eval {$parser->parsefile($file);};
sub StartTag {
my ($expat, $tag, %attrs) = @_;
if(%attrs)
{
print "Attributes:\n";
while(my($key, $value)=each(%attrs))
{
print "\t$key => $value\n";
}
};
if ($expat->within_element('products'))
{
push (@tagstack,lc($tag));
if ($tag eq'category')
{
# do whatever with the attributes ...
}
}
}1;