In the man page for XML::Parser (which is the module generating the error), there is a section titled ENCODINGS, which explains how to work with non-unicode data.

Part of the explanation mentions @XML::Parser::Expat::Encoding_Path, which is a list of one or more directories where encoding definitions are kept. You're likely to find a directory called "Encodings" under XML/Parser/ (wherever this module was installed on your system).

On the system I'm using at the moment (macosx, perl 5.8.6, XML::Parser version 2.34), that Encodings directory contains the follow shift-jis related encoding map files:

x-sjis-cp932.enc x-sjis-jdk117.enc x-sjis-jisx0221.enc x-sjis-unicode.enc
If I take the xml snippet from the OP, and change the name of the encoding from "shift-jis" to "x-sjis-unicode", it does not generate an error.

Also, rather than altering the xml data file, if I get my xml object like this:

my $parser = new XML::Parser(ProtocolEncoding=>"x-sjis-unicode");
this encoding spec overrides the encoding named in the xml file, and it generates no error. (And of course, if I use the data as posted and do not set ProtocolEncoding for the parser object, I get the same error as the OP.)

I'm just guessing that the one I picked is "the right one". Good luck with that.


In reply to Re: Parsing shift-jis XML with XML::TWIG by graff
in thread Parsing shift-jis XML with XML::TWIG by jabarin

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.