Output required as : Jhon,Ram,Rahim code I tired ...<application_list> <application id = "111"> <contacts> <technical> <name>John</name> <name>Ram</name> <name>Rahim</name> </technical> </contacts> </application> <application_list>
I tired above code but not getting comma separated values in o/p : JhonRamRahim#! /usr/bin/perl use warnings; use strict; use XML::XPath; my $appxml = 'ApplicationList.xml'; my $appxp = XML::XPath->new(filename => $appxml); my $xp = $appxp->findnodes('//application_list/application/'); my %appid; my @apprecords; foreach my $appnodeset ($xp->get_nodelist) { my $id = $appnodeset->find('@id')->string_value; $id =~ s/^\s+|\s+$//g; foreach my $spltname ($appxp->findnodes('./contacts/technical',$ap +pnodeset)) { my $name = join ",", map $_->string_value, $spltname->findno +des('.//name1'); # add this as suggested by choroba $appid{$id} = $name; print $name; } }
In reply to get common node of xml in comma separated string by snehit.ar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |