in reply to perl xml parsing

You overwrite the file handle by
$fh_o = Dumper ($data);
You probably wanted to assign the output to $_ to be printed later, so replace this line with
$_ = Dumper ($data);
and all should work.

Replies are listed 'Best First'.
Re^2: perl xml parsing
by poper12 (Initiate) on May 25, 2012 at 14:43 UTC

    I tried this out but i got an error again (could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX GLOB(0xf9def4))

    #!/usr/bin/perl use XML::Simple; use Data::Dumper; $xml = new XML::Simple; $data = $xml->XMLin("news2Obama.xml"); open $fh_o, '>', 'new_output.txt' or die "can't open file: $!"; $_ = Dumper ($data); print $fh_o; close $fh_o or die "can't close file:$!";

      From the command line run this:

      perl -MXML::SAX -e "XML::SAX->add_parser('XML::SAX::PurePerl')->save_p +arsers()"

      Also consider adding the following lines to your code:

      use strict; use warnings;

      See Use strict and warnings.

        no luck.. Is there anything else i can change inside the code to get the xml data stored in the txt?