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

http://search.cpan.org/grep?cpanid=MSERGEANT&release=XML-Parser-2.36&string=Couldn%27t+open+encmap&i=1&n=1&C=0
http://cpansearch.perl.org/src/MSERGEANT/XML-Parser-2.36/Parser/Encodings/README
  • Comment on Re^2: Error with .xml file processing in XML::Simple

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

    Thanks for the reply - thats put me on the right track :)

    I downloaded ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT , and saved as a .enc file, and then uploaded to the folder where my script is.

    It says:

    This function looks for a file in the path list @XML::Parser::Expat::Encoding_Path, that matches the lower-cased name with a '.enc' extension. The first one it finds, it loads.


    ..but how do I set it, so that it knows to look in this path?

    TIA

    Andy

      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.
        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