#!/usr/opt/perl5/bin/perl -sw # use strict; use XML::Twig; # my $xmlfile=@ARGV; my $twig = XML::Twig->new(); $twig->parsefile($xmlfile); my $root = $twig->root; my @nodes1 = $root->get_xpath('//Holding'); for my $hold (@nodes1){ print "\nId = ".$hold->att('id')."\n"; my @nodes2 = $hold->get_xpath('Policy/KeyedValue/KeyValue'); for $_ (@nodes2){ print $_->prev_sibling_text." = "; print $_->text."\n"; } } ./twig3.pl -xmlfile=a2b9f375-51fe-41a1-86ab-069561517890.xml Id = Holding_a344e55a-1471-4c90-aa94-481b434a5b12 AccountType = UTMA_UGMA CheckIndicator = No 1035ExchangeIncluded = No SponsorName = Transamerica Id = Holding_8f6e6000-6cc5-4e7a-b5e8-3acd2ee03468 OldProductType = 401K