Contrary to popular belief, wrapping a call to XML:Parser in an eval, provided it's a block eval, is completely kosher and does not inflict a huge (or actually any) performance penalty. In any case the actual parsing takes much longer than eval-ing a short string even if you choose to use the string version of eval. You can have a look at the review for a way to do this.

Now if you are trying to check tons of files you might want to use James Clarke sp. James Clarke is the guy who wrote the expat library on which XML::Parser is based. He also wrote part of XML-the-spec, groff and way to many things for me to list here... The interesting part is that sp is an SGML parser, which means that you will have to set a couple of environment variables to get it to parse XML (quite easy to do) but also that it will not stop at the first error in the file an try its best to find other errors. It will also probably be faster than using XML::Parser.


In reply to Re: well formed xml by mirod
in thread well formed xml by marvell

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.