I have the following problem when using module 'XML::Simple'. I have an XML config file 'local.xml' that 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 &amp;&amp; ./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>
I want to parse this XML file and extract some values. My script 'foo.pl' looks like this:
#!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";
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

In reply to Problem using module XML::Simple by adam_2005

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.