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

The following code:

#!e:/Perl/bin/Perl.exe -w use strict; use warnings; use diagnostics; use XML::Simple; use CGI qw(:all *table); use CGI::Pretty qw( :all ); use Data::Dumper; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use URI::Escape; my $xml = XMLin( shift ); print Dumper( $xml );

result's in:

C:\test>test.pl C:\test\test.xml Content-type: text/html <H1>Software error:</H1> <PRE> not well-formed at line 46, column 20, byte 1554 at E:/Perl/site/lib/X +ML/Parser.pm line 168 </PRE> <P> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. [Tue Jun 18 15:01:24 2002] C:\test\test.pl: [Tue Jun 18 15:01:24 2002] C:\test\test.pl: not well-formed at line 46 +, column 20, byte 1554 at E:/Perl/site/lib/XML/Parser.pm line 168 C:\test>

What do I need to do to get the error messages to relate to the input file rather than the XML::Simple module source?

Replies are listed 'Best First'.
Re: XML::Simple Error Messages
by mirod (Canon) on Jun 18, 2002 at 14:30 UTC

    I would think that passing the ErrorContext parameter to XML::Parser would display the faulty line:

     XMLin( shift(), parseropts => [ ErrorContext => 1 ]);

      Perfect, Thankyou.