Hello,

Here s my problem (which I can't solve since a long long tiiiime), I can live with it but I was wondering if it could be solved :)

1/ I have a perl script reading a XML file :
<conf name="snoopdogg" serial="1" target="172.16.1.3"> <services> <service name="cpu"> <plugins> <plugin name="cpu" target="172.16.1.3" schedule="60"> <probes> <probe name="load1"> <warn value="4" operator="&gt;"/> <crit value="10" operator="&gt;"/> </probe> (...)
2/ I read it this way :
my $configuration = $xml->XMLin( $conf, GroupTags => { services => 'service', plugins => 'plugin', probes => 'probe' }, ForceArray => [ qw(service plugin probe) ], KeyAttr => { 'service' => 'name', 'plugin' => 'name', 'probe' => 'name' }, KeepRoot => 0 );
The problem is the following : I want to access a probe's warn value, to do so I have to :
my $warn = $configuration->{snoopdogg}{services}{cpu}{plugins}{cpu}{pr +obes}{load1}{warn}{value};
What I would like is to access the value this way :
my $warn = $configuration->{snoopdogg}{cpu}{cpu}{load1}{warn}{value};
Is there a way with XML::Simple to achieve something like
GroupTags => { services => 'service' => name }
Thank you very much ! :)

In reply to Question about XML::Simple by euz

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.