[XML-SIG] pydom vs. 4DOM

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Tue, 16 Oct 2001 09:08:37 +0200 (CEST)


On Mon, 15 Oct 2001, markus jais wrote:

> hello
> I am new to xml with python and there is something I do not
> completely understand!
> 
> in my book "xml processing with python" from prentice hall
> the author speaks of 2 dom implemenation for python:
> pyDOM and 4DOM

PyDOM was shipped with PyXML < 0.6. It has disappeared one year ago or
something, so I guess you book is slightly out of date. The core of 4DOM
has not changed too much, although I think the way of parsing XML
documents into DOMs has changed a bit (though the old API is still there
for backward compatibility). You should now use:
from xml.dom.ext.reader.Sax2 import Reader

r = Reader()
document = r.fromString(mystr)
or 
document = r.fromUri(someUri)

 
> I am a little bit confused.
> can anybody tell me, what is up to date and what DOM implementation
> to use??

miniDOM and 4DOM are OK to use. 4DOM is more spec compliant than miniDom,
so if you need a fairly compete support of the spec, you should use
4DOM. However, there is a cost : 4DOM trees eat up more memory, and
manipulation are slower (lot of checking is done which is not done in
miniDom). 

If you install 4Suite, you'll also find pDomlette and cDomlette, which are
other implementation of the DOM, not as compliant as 4DOM, but
faster. cDomlette is written in C, currently read only, but *very* fast. 

I think PyXML also features PullDom, but I've never used it. The main
advantage of PullDom is that the document is not parsed completely untill
you actually try to access the data from the dom. 

So the answer is : tell us what you want to do, and we'll tell you which
implementation to use.


Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).