#use warnings; use strict; use XML::XPath; use XML::XPath::XMLParser; my $start=' '; print "Enter the Input File name\n"; my $input=; chomp($input); print "Enter the Output File name\n"; my $output=; #my $output="Check"; chomp($output); my $output_file="$output".".xml"; unlink("$output_file"); open(fh,"<$input"); my @xmlsource= ; close fh; #dummy xml my $xmlsource ="@xmlsource"; my ($addrees_Sheet,$amenties_sheet,$unit_mix); if($xmlsource=~m/; # chomp($addrees_Sheet); # my $amenties_sheet="Amenities_1"; # my $unit_mix="UnitMix_1"; open(FH,'>:utf8',"$output_file"); print FH $start."\n"; print FH "\t\t".'
'."\n"; my $add_att='@ss:Name="'.$addrees_Sheet."\""; my $ame_att='@ss:Name="'.$amenties_sheet."\""; my $uni_att='@ss:Name="'.$unit_mix."\""; my $add_path='/Workbook/Worksheet['.$add_att.']/Table/Row[position() > 1]/Cell/Data/node()'; my $add1_path='/Workbook/Worksheet['.$add_att.']/Table/Row[2]/Cell[3]/Data/node()'; my $ame_path='/Workbook/Worksheet['.$ame_att.']/Table/Row[position() > 1]/Cell[3]/Data/node()'; my $uni_path='/Workbook/Worksheet['.$uni_att.']/Table/Row[position() > 1]/Cell/Data/node()'; my $xp = XML::XPath->new(filename =>$input); my $nodeset4 = $xp->find("$add_path"); my ($count,$count1); foreach my $node ($nodeset4->get_nodelist) { my $value=XML::XPath::XMLParser::as_string($node); $count++; if($count==4) { print FH "\t\t\t".''.$value.''."\n"; } if($count==5) { print FH "\t\t\t".''.$value.''."\n"; } if($count==6) { print FH "\t\t\t".''.$value.''."\n"; } if($count==7) { print FH "\t\t\t".''.$value.''."\n"; } } print FH "\t\t".'
'."\n"; print FH "\t\t".''."\n"; #my $nodeset1 = $xp->find('/Workbook/Worksheet[@ss:Name="$amenties_sheet"]/Table/Row[position() > 1]/Cell[3]/Data/node()'); my $nodeset1 = $xp->find("$ame_path"); foreach my $node ($nodeset1->get_nodelist) { my $value=XML::XPath::XMLParser::as_string($node); print FH "\t\t\t".''.$value.''."\n"; } print FH "\t\t".''."\n"; #my $nodeset2 = $xp->find('/Workbook/Worksheet[@ss:Name="$addrees_Sheet"]/Table/Row[2]/Cell[3]/Data/node()'); my $nodeset2 = $xp->find("$add1_path"); foreach my $node ($nodeset2->get_nodelist) { my $value=XML::XPath::XMLParser::as_string($node); print FH "\t\t".''.$value.''."\n"; } print FH "\t\t".''."\n"; my ($max_r,$min_r,$max_sq,$min_sq,$bed,$bath,$units); #my $nodeset3 = $xp->find('/Workbook/Worksheet[@ss:Name="$unit_mix"]/Table/Row[position() > 1]/Cell/Data/node()'); my $nodeset3 = $xp->find("$uni_path"); my $node_count=1; foreach my $node ($nodeset3->get_nodelist) { print "node_count:$node_count\n"; #<>; $node_count++; my $value=XML::XPath::XMLParser::as_string($node); $count1++; # my $value1=$node->getNodeValue; # print "value:$value1\n"; $units=''; $max_r=''; $max_sq=''; if($count1==3) { $bed=''.$value.''; } if($count1==4) { $bath=''.$value.''; } if($count1==5) { $min_sq=''.$value.''; } if($count1==6) { $min_r=''.$value.''; print FH "\t\t\t".''."\n"; print FH "\t\t\t\t".$min_r."\n"; print FH "\t\t\t\t".$max_r."\n"; print FH "\t\t\t\t".$min_sq."\n"; print FH "\t\t\t\t".$max_sq."\n"; print FH "\t\t\t\t".$bed."\n"; print FH "\t\t\t\t".$bath."\n"; print FH "\t\t\t\t".$units."\n"; print FH "\t\t\t".''."\n"; undef $count1; } } print FH "\t\t".''."\n"; print FH '
'; close FH;