Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^3: Parse XML into CSV Files

by alexm (Chaplain)
on Jul 21, 2009 at 19:53 UTC ( #782065=note: print w/replies, xml ) Need Help??

in reply to Re^2: Parse XML into CSV Files
in thread Parse XML into CSV Files

Once you remove the last <Vehicle> tag from the XML, the XMLin parser should read the file and then you can iterate over the vehicle array like this:

my @vehicle_list = @{ $config->{Vehicle} }; foreach my $vehicle ( @vehicle_list ) { print $vehicle->{AuctionID} . "\n"; }

Replies are listed 'Best First'.
Re^4: Parse XML into CSV Files
by dmsparts (Sexton) on Jul 22, 2009 at 08:07 UTC
    Thanks for the reply,

    This is what i have found in another post on here,

    It seems to work fine until i get a XML TAG with no data in it. ie,
    <Mileage> </Mileage>

    When i print this variable to either the screen or an output file i get a value such as,


    Any ideas how to stop this??

      Any ideas how to stop this??

      This is the default behaviour for XMLin with empty elements, but you can change it, e.g.:

      my $config = XMLin( $xml, SuppressEmpty => "" );

      See XML::Simple for the details.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://782065]
[Corion]: There are worse ways to enter a website ;)
[Lady_Aleena]: Corion, I'm just hoping Cookies doesn't get too annoying.

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2017-04-26 08:00 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (471 votes). Check out past polls.