XML question, DOM or SAX?

sismex01 at hebmex.com sismex01 at hebmex.com
Fri Oct 18 11:43:31 EDT 2002


> From: Markus von Ehr [mailto:markus.vonehr at ipm.fhg.de]
> 
> Hi Gustavo,
> 
> no, I don't have rgb values, inside one spec I have about 1000
> values representing spectral lines.
> I don't want to enclose every value inside something like
> <red>
> </red>
> the efficiency would be very bad...
> 
> Markus
>

Well, there's that, but IMHO, XML wasn't meant for efficiency,
but for expressiveness.  If you want speed and efficiency, but
to keep a measure of readability, you could use an ordinary
text file, where all contents for a single <spectra>...</spectra>
could be in a single line:

    0.11 0.3 0.3 0.4
    0.2 0.4 0.11
...

So, when you read it all vía an ordinary text-reading application,
line per line, you can also split it all with a single
statement:

  spectra = [ float(s) for s in textfile.readline().split() if s ]

so keep reading until you get an empty spectra array.

simple, no?

-gustavo




More information about the Python-list mailing list