try this code for your search
Thanks and Regards,my $xml_str = '<List> <Events WID="1"> <Event Confirmed="Y"> <Country>USA</Country> </Event> <Event Confirmed="Y"> <Country>UK</Country> </Event> <Event Confirmed="Y"> <Country>CANADA</Country> </Event> </Events> <Events WID="2"> <Event Confirmed="Y"> <Country>MEXICO</Country> </Event> <Event Confirmed="Y"> <Country>INDIA</Country> </Event> <Event Confirmed="Y"> <Country>CHINA</Country> </Event> </Events> </List>'; parse_xml($xml_str); sub parse_xml { use XML::LibXML; no warnings; my $Country = (); my @List = (); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($_[0]); foreach my $ca_isins ($doc->findnodes('/List/Events')) { my ($id) = $ca_isins->findnodes('@WID'); $widValue=$id->to_literal; my (@titleCountry) = $ca_isins->findnodes('./Event//Country'); + foreach (@titleCountry){ push (@List, ($_->to_literal, '|', $widValue, "\n")); } } print "@List"; }
In reply to Re^2: XPathing Up level
by yuvanbala
in thread XPathing Up level
by mr_p
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |