I am trying to parse and XML file from weather.com. The file they send is pretty complicated so I wanted to first try a simpler file -- I tried the example given in the docs for XML::Simple. I can't get the example to print out individual element data
I've included the perl code and the XML file.
If I print the "Dumper ($config)" out I get the data.
If I try and print an individual element out though with either of the lines below, I just get a "use of uninitialized value" message. I've tried every combination I can think of to print out individual element data out but I just can't get the sytax correct. Thanks for your help and suggestions.
Possibly XML::Simple isn't what I need. Any other ideas?
#Used to get weather data from weather.com
use XML::Simple qw(:strict);
my $weatherdata = get($url);
my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 1, KeyAttr=>);
my $config = $xs->XMLin($weatherdata);
#print Dumper($config); #Printing this out works fine.
<config logdir="/var/log/foo/" debugfile="/tmp/foo.debug">
<server name="sahara" osname="solaris" osversion="2.6">
<server name="gobi" osname="irix" osversion="6.5">
<server name="kalahari" osname="linux" osversion="2.0.34">