![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: Help with XML-SAX program ... it's driving me nuts ...
From: Fredrik Lundh <fredrik@pythonware.com>
Date: Tue Jan 31 2006 - 13:59:34 CET
mitsura@skynet.be wrote:
> I need to read a simle XML file. For this I use the SAX parser. So far
> The strange thing is that for some reason, the attributes for all the
you're using the same dictionary for all Service elements:
obj.attributes = self.attribs
adds a reference to the attribs dictionary; it doesn't make a copy (if it
changing
self.attribs.clear()
to
self.attribs = {} # use a new dict for the next round
fixes this.
> It's driving me nuts. I have spend hours going through this very simple
simple? fwiw, here's the corresponding ElementTree solution:
import elementtree.ElementTree as ET
for event, elem in ET.iterparse("kd.xml"):
(tweak as necessary)
</F>
|