#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use XML::Twig; my $twig = XML::Twig -> parsefile ( 'data/misc/test.xml' ); foreach my $node ( $twig -> get_xpath ( '//*' ) ) { print $node -> tag, ": ", $node -> text,"\n"; } #### print $twig -> root -> first_child_text('name'),"\n"; print $twig -> root -> first_child('profcats') -> first_child_text('name'),"\n"; foreach my $element ( $twig -> root -> children ) { print $element -> tag, ": ", $element -> text,"\n"; foreach my $sub ( $element -> children ) { print "\t",$sub -> tag, ": ", $sub -> text,"\n"; foreach my $subsub ( $sub -> children ) { print "\t\t",$subsub -> tag, ": ", $sub -> text,"\n"; foreach my $subsubsub ( $subsub -> children ) { print "\t\t\t", $subsubsub -> tag, ": ", $subsubsub -> text,"\n"; } } } }