in reply to Re^3: Error with .xml file processing in XML::Simple
in thread Error with .xml file processing in XML::Simple

The respective piece of code that populates @Encoding_Path looks like

if ($have_File_Spec) { @Encoding_Path = (grep(-d $_, map(File::Spec->catdir($_, qw(XML Parser Enco +dings)), @INC)), File::Spec->curdir); } else { @Encoding_Path = (grep(-d $_, map($_ . '/XML/Parser/Encodings', @INC +)), '.'); }

so it should work if you put the file in "the current directory", or in one of the @INC dirs with /XML/Parser/Encodings appended. If you try '.', note that if this a CGI script, the current directory may not be what you think it is... (in case of doubt, chdir()).

Alternatively, I think you can explicitly call XML::Parser::Expat::load_encoding(ENCODING) and specify an absolute path to the file as ENCODING.  From Expat.pm:

=item XML::Parser::Expat::load_encoding(ENCODING) Load an external encoding. ENCODING is either the name of an encoding +or the name of a file. The basename is converted to lowercase and a '.enc +' extension is appended unless there's one already there. Then, unless it's an absolute pathname (i.e. begins with '/'), the first file by th +at name discovered in the @Encoding_Path path list is used. (...) The only reason users should use this function is to explicitly load an encoding not contained in the @Encoding_Path list.

Replies are listed 'Best First'.
Re^5: Error with .xml file processing in XML::Simple
by ultranerds (Hermit) on Feb 17, 2009 at 10:16 UTC
    Hi,

    Thanks for the reply. I tried using another "lib" (to the current folder), but that didn't work either.

    Guess I'll just have to contact the host, and see if they can suggest anything.

    Thanks for the reply though :)

    Cheers

    Andy
      I tried using another "lib" (to the current folder)

      From looking at the above code I'd say that "use lib qw(.)" shouldn't be necessary and wouldn't help.  It should simply work if the file is found in the current directory.

      And if you use lib qw(/some/path), the file would need to be located in /some/path/XML/Parser/Encodings/ — IOW, if /some/path is '.', the file would need to be put in ./XML/Parser/Encodings/.

      (Also make sure that the webserver can access the directory.)

      Unless you've modified it elsewhere in your script &/or environment, @INC already contains the current directory i.e. ..

      A user level that continues to overstate my experience :-))
        Ah, just realised a silly mistake :P It wasn't called .enc :P

        Anyway, renamed it - and now get this error:

        <pre>./iso-8859-15.enc isn't an encmap file at /usr/lib/perl5/vendor_p +erl/5.8.4/x86_64-linux/XML/Parser.pm line 187 </pre> <p> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. </p> [Tue Feb 17 07:09:51 2009] import.cgi: ./iso-8859-15.enc isn't an encm +ap file at /usr/lib/perl5/vendor_perl/5.8.4/x86_64-linux/XML/Parser.p +m line 187


        Any more suggestions?

        TIA!

        Andy
        Mmm weird - well, the file is certainly in the same directory, but its still fataling out :( Cheers Andy