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 reply to Re: error returned with XML::Simple or Data::Dumper by grantm
in thread error returned with XML::Simple or Data::Dumper by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.