Hello, Despite extensive research on the internet into previous work that has been done on this topic I could not find any useful bit of information. So I hope someone here will be able to help me out.

I am trying to parse and XML file that is shift-jis encoded using XML::Twig. From what I gather, XML::Twig can parse shift-jis assuming the XML is well formed. However, I haven't been able to get it to do that yet. So far I've done the following: in my XML::Parser directory under Parser/Encoding I set my shift-jis encoding file to be x-sjis-unicode.enc (renamed the file to shift-jis.enc).

When I try to parse my XMl file I get the following error:

unknown encoding at line 1, column 30, byte 30 at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser.pm line 185

The first few lines of my XML file look as follows (note the <RetrunString> tag should contain shift-jis characters):

<?xml version="1.0" encoding="shift-jis" ?> <!DOCTYPE AdminRequest (View Source for full doctype...)> <AdminReques +t> <Header> <ReturnCode>0</ReturnCode> <ReturnString></ReturnString> </Header>


Can you please let me know what I am doing wrong or how I can go about parsing shift-jis? If you can point me to examples that'd be appreciated. Thanks.

In reply to 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.