Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: error returned with XML::Simple or Data::Dumperby grantm (Parson) |
on Jul 19, 2010 at 01:14 UTC ( [id://850187]=note: print w/replies, xml ) | Need Help?? |
That message is a warning (rather than an error) which comes from the XML::SAX::PurePerl parser module. The EncodingDetect.pm file contains a routine to guess what encoding the source document uses. The routine will only be invoked if your source document does not start with an XML declaration that declares the encoding. So if you get an encoding declaration added to the document when it is generated then the warning will go away. The encoding detection routine has very simple logic. It first looks at the first few bytes of the file to see if it starts with a 'Byte Order Mark' (BOM). If a BOM is present, the encoding will be detected automatically. If there is no BOM but the first four bytes are ASCII "<?xm" then UTF-8 encoding is assumed. If the first non-whitespace byte is ASCII "<" then UTF-8 encoding is assumed. Finally a check is done to see if the bytes look like EBCDIC. If all these checks fail (as is happening in your case) and the warning is emitted, UTF-8 encoding is assumed and parsing will continue. However it seems very unlikely you have a valid XML document if none of those checks were successful. The most likely scenario is that the input XML is either undefined or an empty string. I recommend you go back and throw in a 'print' to confirm you really do have some XML.
In Section
Seekers of Perl Wisdom
|
|