in reply to XML::Simple element handling
Brer Monk,
I wrote a quick little ditty to check out your XML as follows:
When I ran my code I noticed the following oddity in the Data::Dumper output:#!/usr/bin/perl -w use strict; use XML::Simple; use Data::Dumper; my $stuff=XMLin(); print Dumper($stuff);
$VAR1 = { 'server' => { 'location' => 'atlanta', 'name' => 'cns04-fs16', 'event' => { 'name' => 'diskname > online 6.43 days 10.10.10.10 yellow Thu Mar 30 15:03:16 EST 2006 Disk on cns04-fs16 at WARNING level yellow /mail/vol/cns04-fs16 (93%) has reached the defined disk sp +ace WARNING level (92%) titan atlanta Storage Servers Bluearc Servers basys online 6.44 days 10.10.10.10 yellow Thu Mar 30 15:05:12 2006 yellow node 1 is in status (notUp) yellow TITANPC-2 is in status (notUp) yellow EVS006 is in status (offLine) ' }, 'grouping' => { 'secondary' => 'Mail Filers', 'primary' => 'Storage Servers' } } };
Immediately I suspected that your XML had some sort of error in it and lo and behold, if I changed one line from
to<name>disk</ name >
eliminating the extra space after the closing tag's slash and when I reran my test I got:<name>disk</name>
$VAR1 = { 'server' => { 'titan ' => { 'location' => 'atlanta', 'grouping' => { 'secondary' => 'Bluear +c Servers', 'primary' => 'Storage +Servers' }, 'event' => { 'sparedata' => {}, 'entry' => [ { 'color' => ' +yellow', 'desc' => 'n +ode 1 is in status (notUp)' }, { 'color' => ' +yellow', 'desc' => 'T +ITANPC-2 is in status (notUp)' }, { 'color' => ' +yellow', 'desc' => 'E +VS006 is in status (offLine)' } ], 'received_by' => '10.10.1 +0.10', 'name' => 'basys', 'state' => { 'name' => 'onl +ine', 'data' => {} }, 'received_at' => 'Thu Mar + 30 15:05:12 2006', 'length' => '6.44 days', 'color' => 'yellow' } }, 'cns04-fs16' => { 'location' => 'atlanta', 'grouping' => { 'secondary' => 'Ma +il Filers', 'primary' => 'Stor +age Servers' }, 'event' => { 'sparedata' => 'Disk +on cns04-fs16 at WARNING level', 'entry' => { 'color' => + 'yellow', + 'desc' => '/mail/vol/cns04-fs16 (93%) has reached the defined disk s +pace WARNING level (92%)' }, 'received_by' => '10. +10.10.10', 'name' => +'disk', 'state' => { 'name' => +'online', 'data' => +{} }, 'received_at' => 'Thu + Mar 30 15:03:16 EST 2006', 'length' => '6.43 day +s', 'color' => 'yellow' } } } };
That to my eye looks much better.
Now, I must confess that my XML foo is not quite what it should be so I'm not sure if the space after the closing tag's slash is allowed there or not, but I'm not arguing with results. Either the XML was incorrect or there is a parsing issue with XML::Simple.
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Simple element handling
by linwood (Initiate) on May 10, 2006 at 18:01 UTC | |
by blue_cowdawg (Monsignor) on May 10, 2006 at 18:30 UTC |