|XP is just a number|
xml parsers: do I need one?by regan (Sexton)
|on Aug 28, 2003 at 14:05 UTC||Need Help??|
regan has asked for the
wisdom of the Perl Monks concerning the following question:
<suckup> oh Holders of great Perl Wisdom </suckup>
I wrote a few weeks ago about a problem with hashes, and mentioned that I was parsing xml with regexs. I got more comments that I need to use a parser, than help with the problem, but the problem was solved. I promised to investigate using a parser for my work. I've done a bit of looking, and am not sure what to do now: Here's my dilemma:
-I am parsing an xml file with about 9000 xml highest level elements
-The xml file is about 3.3MB long.
-The xml file is generated by another application that I wrote, and I know EXACTLY how the xml will look. I don't need to worry about element ordering, or if an element exists.
-The xml file is used by major applications where I work for, and is not going to change for my new app.
-I tried using the bare-bones code in the XML::Parser tutorial to parse through the file. All it does, is look at the element type, discovers that the element is not <message>, and returns. The parser has been running for more than 10 minutes, and shows no signs of stopping.
-When I parsed this with regexs, it took a minute or two to parse. I didn't parse all the element types, but I did go through the whole file.
-The application needs to suck up all the xml, process it, and spit out a huge HTML page. So far, due to speed issues, the regex approach is winning hands down.
I'm not including any code or data, because the solution to this problem probably does not rest solely on code issues, rather tradeoffs between readable code (xml Parser) and speed (regexs).