I need to write a script that parses several XML files, collecting information from them to write to an output file. I have used XML::Parser to do this kind of thing before, but only on files that have a !DOCTYPE line at the top that indicates a dtd file for the XML file being parsed. The XML files I am working with now do not have !DOCTYPE lines. It apparently will not necessarily be possible for users of my script to edit the XML files and insert a !DOCTYPE line in them, so I have to use the XML files as they are. Now, when I run the first draft of my script on one of these files, it returns an error when it hits a line like: <restriction text="Cannot be used worldwide for Art d&eacute;cor" /> The entity declarations in a dtd file would indicate how &eacute; should be interpreted, and I am wondering what I can do to parse tags that contain entities like this when a dtd file is not available. I have tried various things with the handlers and other arguments of XML::Parser, but I haven't found the right configuration to make it work. Is there something that I have simply overlooked, or do I need to use a different approach?

In reply to Using XML::Parser on a file without a !DOCTYPE line by moleary

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.