#! perl -w use warnings; use strict; use XML::XSH2; my $tempVal = XML::XSH2->new( twig_handlers => { /httpsRoutes/httpsRoute } ); $tempVal->parsefile("c:\\location\\test.xml"); for ($tempVal) { echo @hostname (key) @tier | cat > out.txt; }