$ perl use XML::Twig ; XML::Twig->new( twig_handlers => { 'coordinates' => sub { print $_->xpath, "\n"; print $_->trimmed_text, "\n\n"; }, }, )->xparse( "somefile.xml" ); __END__ /on/no/coordinates ro /on/ma/to/peia/coordinates sham /on/coordinates bo /on/coordinates[2] Asin (I) - Biography $ cat somefile.xml ro sham bo Asin (I) - Biography]]>