[Tutor] A somewhat easier way to parse XML

David Rock david at graniteweb.com
Wed Jan 19 04:58:33 CET 2005


* Max Noel <maxnoel_fr at yahoo.fr> [2005-01-19 00:17]:
> Hi everyone,
> 
> 	I've just spent the last few hours learning how to use the DOM XML 
> 	API (to be more precise, the one that's in PyXML), instead of revising for 
> my exams :p. My conclusion so far: it sucks (and so does SAX because I 
> can't see a way to use it for OOP or "recursive" XML trees).
> 	I'm certain it can be used to do extremely powerful stuff, but as 
> 	far as usability is concerned, it's ridiculously verbose and naming is 
> inconsistent. I've had a look at Java DOM as well, and it's apparently 
> the same.

I'm kind of in the same boat as you are and I have come to the
conclusion that XML is intended to answer specific questions with
discreet answers, not walk the DOM to create a dictionary. I _think_ the
idea behind this is that it would be redundant. You already have a
"dictionary" of sorts in the XML itself, why create a new one? 

For me, it seems that the way you are supposed to interact with an XML
DOM is to already know what you are looking for, and in theory, you
_should_ know ;-)

Still, I can't help wishing I had a simple way to create a dict from a
DOM. From a Python perspective, that seems more "Pythonic" to me as
well. I guess it's just a different way of looking at it.

-- 
David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20050118/025f3bf0/attachment.pgp


More information about the Tutor mailing list