Sidd has asked for the wisdom of the Perl Monks concerning the following question:

Below is the code snippet that I am using to read an XML file placed in a different directory. But this doesnt seem to work. Can somebody please help me out with this or suggest a way around to read the XML. I want to use XML::Simple to do this. Thanks.
my $shoeConfig = XMLin("F:/Inetpub/ecomm-static/US/html/mi_home_page/h +ome_flash.xml"); print OUT "After ShoeConfig"; foreach my $shoe(@{$shoeConfig->{ShoeBank}{Shoe}}){ my $img = $shoe->{Image}; my $swf = $shoe->{MainClip}; print OUT "\n OUTPUT:".$img.$swf; }

Replies are listed 'Best First'.
Re: XMLin not able to read the input XML file
by moritz (Cardinal) on Aug 26, 2011 at 12:02 UTC
    But this doesnt seem to work.

    Please be more specific. Is there blue fire coming out of your PC when you try it? Or do you get an error message? If yes, which?

Re: XMLin not able to read the input XML file
by dasgar (Priest) on Aug 26, 2011 at 12:46 UTC

    I agree with moritz that you're not providing quite enough information for others to figure out what the problem is. However, I would suggest that you double check your XML file to ensure that it is compliant XML.

    If you look at the "Caveats" subsection under the "Description" of the documentation for XML::Simple, it explains some things that need to be done in order for XMLout to produce compliant XML that can be read back in with XMLin. Check to see if the "rules" mentioned there are being followed by your XML file.

    Also, the "Error Handling" section mentions the need for the XML input to be compliant XML. You can try using the eval block like the example given there to see if that will provide you with more details on problems with parsing the XML file.

    If you're having problems trying to figure out the data structure of what was read in, I'd suggest that you try using something like Data::Dumper or Data::Show to help out.

Re: XMLin not able to read the input XML file
by toolic (Bishop) on Aug 26, 2011 at 13:01 UTC
Re: XMLin not able to read the input XML file
by kcott (Archbishop) on Aug 27, 2011 at 09:03 UTC

    Assuming you're using XML::Simple:

    use XML::Simple;

    Try using XML::Simple's Strict Mode:

    use XML::Simple qw(:strict);

    That may help to track down whatever it is that currently "doesnt seem to work".

    Note: Use this in addition to normal strictures and warnings rather than as a replacement, i.e.

    use strict; use warnings; ... use XML::Simple qw(:strict);

    -- Ken