in reply to Problem with parsing an XML using XML::Simple

Yes you can do it by XML::Simple, take a look below

use strict; use warnings; use XML::Simple; use Data::Dumper; my $xml = q~<?xml version="1.0" encoding="utf-8" ?> <Config type="Tabs"> <Core active="true"> <CategoryID>a</CategoryID> </Core> <ShoeBank> <default>1</default> <Shoe> <Name>a</Name> <Image>a.jpg</Image> <MainClip>a.swf</MainClip> <ShoeConfigXML>a.xml</ShoeConfigXML> </Shoe> <Shoe> <Name>b</Name> <Image>b.jpg</Image> <MainClip>b.swf</MainClip> <ShoeConfigXML>b.xml</ShoeConfigXML> </Shoe> </ShoeBank> </Config>~; print $xml,$/; my $data = XMLin($xml); print Dumper( $data ); foreach my $test (@{$data->{ShoeBank}{Shoe}}){ print"Name:$test->{Name} \n"; }

Output: Name:a
Name:b

Replies are listed 'Best First'.
Re^2: Problem with parsing an XML using XML::Simple
by Sidd (Initiate) on Aug 18, 2011 at 10:16 UTC
    Thanks for replying Nikhil. I had tried something similar earlier but it somehow doesn't work for me. Following is the code. Even the dumper shows nothing. The XML is stored in the file home_flash.xml
    my $debug_file = "F:/Interwoven/OpenDeployNG/solutions/perl/comm/a +bc/home_edit_glblcnt.log"; open(OUT, ">$debug_file"); my $xml = XML::Simple->new(); my $shoeConfig = $xml->XMLin('f:\\inetpub\\ecomm-static\\us\\html\ +\mi_home_page\\home_flash.xml'); print OUT Dumper($shoeConfig); foreach my $shoe(@{$shoeConfig->{ShoeBank}{Shoe}}){ my $img = $shoe->{Image}; my $swf = $shoe->{MainClip}; print OUT "\img str - ".$img; print OUT "\swf str - ".$swf; }