#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $t= XML::Twig->new( # the twig will include just the root and selected titles twig_roots => { 'product/STOCK_CODE' => \&print_elt_text, 'product/WHOLESALE_PRICE' => \&print_elt_text, 'product/MAP_Price' => \&print_elt_text, 'product/DISC' => \&print_elt_text } ); $t->parsefile( './workingfiles/eur/eurfeed.xml'); sub print_elt_text { my( $t, $elt)= @_; print $elt->text; # print the text (including sub-element texts) $t->purge; # frees the memory }