I have recently encountered this same problem, but the issue for me is a little more esoteric. I believe that yes, it is important for the XML parser to quit if there is malformed XML data, but the problem for me is with the execution completely stopping altogether.
If I am running through a list of URL's that are XML data and it happens that one of the XML files is out dated and there is an HTML file in place indicating this change, of course the program is going to die. What happens next? You run your program again and it will die at the same place...so it must ignore any non-XML and/or mal-formed XML files.
For non-XML files the test is easy. You can do something like
if(($xml_data =~ m/<\?xml version/){ .. }
For actual XML integrity itself there needs to be some measure, so that you can skip parsing if it will in fact fail during parse. It would be nice to modify the expat itself so that instead of dying it will return a failed status. This would give more control to the programmer and is stylisticallly better.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.