Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
<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).

In reply to xml parsers: do I need one? by regan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-23 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found