[XML-SIG] building XML docs using ?

Joe Murray jmurray@agyinc.com
Mon, 14 May 2001 11:22:05 -0700

Dear All,

I am converting many large "legacy" text files to XML.  Some of the
original text files are upwards of 100 MB.  What is the most efficient,
using the speed/memory metrics, way to convert these text files to XML?

Currently, I parse through the text files and create a DOM Document
representation.  However, the time and memory expenditure for conversion
is huge, using either xml.dom.minidom or xml.dom.  Here's an example of
what I do:


# import stuff
from xml.dom.minidom import Document

# create doc and documentElement node
doc = Document()
docelement = doc.appendChild(...)
f = open(...)
while 1:
    # get data from file
    line = f.readline()
    if not line:
    line = line.strip()
    data = line.split(...)
    # create a new element node using data from file
    node = doc.createElement(...)


Should I forgo the ease of using the DOM objects by simply generating
outputting "hand-generated" markup?  I was doing this previously, it's
efficient, but definitely not as nice/clean as it could be...

So basically, is there a lightweight XML module which provides for (as a
graphics programmer would say) "immediate mode" output, with as nice an
interface as the DOM modules?  Oh, and BTW, can XML solve all my
problems???  ;-) 

Thanks much,


Joseph Murray
Bioinformatics Specialist, AGY Therapeutics
290 Utah Avenue, South San Francisco, CA 94080
(650) 228-1146