Re: [Zope] Using ParsedXML from Python script
Hi Brian, Brian Sullivan wrote: I am attempting to extract information from a ParsedXML object using Python script. AFAIR, ParsedXML just uses DOM as its standard, in which case any good DOM reference should give you the primitives you need. A good one lives somewhere on http://www.zvon.org cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ 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 )
Re: [Zope] Using ParsedXML from Python script
(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 )
Re: [Zope] Using ParsedXML from Python script
On 2/10/06, Sascha Welter [EMAIL PROTECTED] wrote: Is that the kind of thing you were looking for? Better than what I have now -- it might get me over the initial hump -- thanks. ___ 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 )
Re: [Zope] Using ParsedXML from Python script
Hi Brian, unless it is mandatory for you to use ParsedXML for your XML needs, you might want to check out Uche Ogbuji's Amara Toolkit ( http://uche.ogbuji.net/tech/4suite/amara/ ). It provides a much more pythonic way of dealing with XML. Regards, Patrick. On 2/10/06, Brian Sullivan [EMAIL PROTECTED] wrote: On 2/10/06, Sascha Welter [EMAIL PROTECTED] wrote: Is that the kind of thing you were looking for? Better than what I have now -- it might get me over the initial hump -- thanks. ___ 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 ) ___ 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 )
Re: [Zope] Using ParsedXML from Python script
On 2/10/06, Patrick Decat [EMAIL PROTECTED] wrote: Hi Brian, unless it is mandatory for you to use ParsedXML for your XML needs, you might want to check out Uche Ogbuji's Amara Toolkit ( http://uche.ogbuji.net/tech/4suite/amara/ ). It provides a much more pythonic way of dealing with XML. Well maybe more pythonic -- but seemingly not zopic? My Python use is in Zope. Or am I missing something? ___ 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 )
Re: [Zope] Using ParsedXML from Python script
I use it with Zope and Zope/CMF Content (Documents, Files, ExternalFiles) from a custom filesystem product. Regards, Patrick. On 2/10/06, Brian Sullivan [EMAIL PROTECTED] wrote: On 2/10/06, Patrick Decat [EMAIL PROTECTED] wrote: Hi Brian, unless it is mandatory for you to use ParsedXML for your XML needs, you might want to check out Uche Ogbuji's Amara Toolkit ( http://uche.ogbuji.net/tech/4suite/amara/ ). It provides a much more pythonic way of dealing with XML. Well maybe more pythonic -- but seemingly not zopic? My Python use is in Zope. Or am I missing something? ___ 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 ) ___ 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 )
[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? ___ 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 )