in reply to Re: XML::Simple element handling
in thread XML::Simple element handling

space must have been added when i was formatting my input. In my xml file the space is not there. with the code below i expect the server elements to be put into an array. this is my perl:
#!/ms/local/perl5.8.0/bin/perl -w use strict; use XML::Simple; use Data::Dumper; my $bbtmpdata = "bb.xml"; my $xml = new XML::Simple; my $bbevents = $xml->XMLin($bbtmpdata, forcearray=>['server']); print Dumper($bbevents);

Replies are listed 'Best First'.
Re^3: XML::Simple element handling
by blue_cowdawg (Monsignor) on May 10, 2006 at 18:30 UTC
        i expect the server elements to be put into an array. this is my perl

    What exactly do you mean by that? Can you post a shortened example of what you want the structure to look like?

    Based on a best guess of what you meant I changed my code to look like:

    #!/usr/bin/perl -w use strict; use XML::Simple; use Data::Dumper; my $stuff=XMLin(undef,KeyAttr=>['server']); print Dumper($stuff);
    which then takes the server element and treats everything enclosed by that as an array. Is that what you were after? Short sample of the structure:
    $VAR1 = { 'server' => [ { 'location' => 'atlanta', 'name' => 'cns04-fs16', 'event' => { 'sparedata' => 'Disk on cns04-fs16 +at WARNING level', 'entry' => { 'color' => 'yellow', 'desc' => '/mail/vol/cns +04-fs16 (9 3%) has reached the defined disk space WARNING level (92%) +' }, 'received_by' => '10.10.10.10', 'name' => 'disk', 'state' => { 'name' => 'online', 'data' => {} }, 'received_at' => 'Thu Mar 30 15:03: +16 EST 200 6', 'length' => '6.43 days', 'color' => 'yellow' }, 'grouping' => { 'secondary' => 'Mail Filers', 'primary' => 'Storage Servers' } },


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg