#!/bin/perl -w

use strict;
use XML::Twig;

my $t= new XML::Twig( TwigHandlers=> { Product => \&product});
$t->parsefile( 'TestTwig.xml');
exit;

sub product
  { my ($t, $product)= @_;
    my %product;
    $product{id}= $product->field( 'ProductID');
    $product{name}= $product->field( 'ProductName');
    $product{description}= $product->field( 'Description');

    $product{category}= join ':', 
                        map {$_->text || ''}   
                        @{[$product->children( 'Category')]};

    print "$product{id}: $product{name} - $product{description}\n";
    print "        : $product{category}\n";
    $product->delete;
  }
