(Thu, Feb 09, 2006 at 12:00:08PM -0500) [EMAIL PROTECTED] wrote/schrieb/egrapse: > From: Brian Sullivan <[EMAIL PROTECTED]> > Subject: [Zope] Using ParsedXML from Python script > > I am attempting to extract information from a ParsedXML object using > Python script. > > I can't seem to get my mind around exactly how this works. Can anyone > point non trivial examples in Python of maniupulating a ParsedXML > object?
This is from a class that is based on ParsedXML.ParsedXML, caveat: It's code from an old project that isn't maintained and maybe it was done suboptimal anyway :-) def get_Status(self): doc = self.documentElement status = doc.getElementsByTagName('Status')[0].getAttribute('Number') return { 'Status':str(status), 'Schema':'ImageID' } another one: def get_photo_count(self): return self.documentElement.getElementsByTagName('Photo').length the manage_addXY method of that object has something like this inside: try: b = NetSelection(id, file, useNamespaces, contentType) except expat.error, e: ... do things here and the class has no explicit __init__ method, so likely we got that from the ParsedXML.ParsedXML base class. also there seems to be stuff that adds/changes things in some methods: if not new_node: new_node = this_Photo.appendChild(doc.createElement(Network_Description)) or: def _set_description_on_node ( self, node, Description_Dictionary ): ''' "sets" the contents of a Dictionary into an XML node ''' for fred in Description_Dictionary.keys(): node.setAttribute( fred, Description_Dictionary[ fred ] ) Is that the kind of thing you were looking for? Regards, Sascha _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )