adam_2005 has asked for the wisdom of the Perl Monks concerning the following question:
I want to parse this XML file and extract some values. My script 'foo.pl' looks like this:<WHICS> <WhicsService> <Parameters> <WHICS> <Value>123.456.7.89</Value> <Detail>Name of Unix system running WHICS</Detail> </WHICS> <ServersMax> <Value>15</Value> <Detail>Maximum number of servers running on WHICS</Detail +> </ServersMax> <Service Name="WR80B"> <Runable> <Value>yes</Value> <Detail>Run WR80B process if value is yes else does not + stat WR80B</Detail> </Runable> <PortOut> <Value>4100</Value> <Detail>Default port for Unix server connections</Detai +l> </PortOut> <command> <Value>cd /whics/ahm && ./bin/wh_wweb80.sh </Va +lue> <Detail>Unix command required to run WR81B</Detail> </command> <ServersMin> <Value>7</Value> <Detail>Minimum number of servers running on WHICS</Det +ail> </ServersMin> </Service> </Parameters> </WhicsService> </WHICS>
The first two 'print' lines work fine but the third 'print line does not print 'yes', instead nothing is printed. Any pointers would be greatly appreciated! Thanks, Adam#!perl use XML::Simple; my $config = XMLin("local.xml"); print $config->{WhicsService}->{Parameters}->{WHICS}->{Value} . "\n"; +# prints '123.456.78.9' print $config->{WhicsService}->{Parameters}->{ServersMax}->{Value} . " +\n"; # prints '15' print $config->{WhicsService}->{Parameters}->{Service}->{WR80B}->{Runa +ble}->{Value} . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem using module XML::Simple
by bobf (Monsignor) on Dec 05, 2005 at 05:27 UTC | |
by davido (Cardinal) on Dec 05, 2005 at 05:40 UTC | |
|
Re: Problem using module XML::Simple
by planetscape (Chancellor) on Dec 05, 2005 at 05:53 UTC | |
|
Re: Problem using module XML::Simple
by Zaxo (Archbishop) on Dec 05, 2005 at 05:44 UTC | |
|
Re: Problem using module XML::Simple
by grantm (Parson) on Dec 05, 2005 at 18:06 UTC |