Ciao, I see that XMLParsed 0.1 b3 is only for generic Unix-like platform, while 0.1 b1 and b2 are for all platforms. Do you know if XMLParsed developers want to abandon Win platform? Thanks, Michele -----Messaggio originale----- Da: Martijn Pieters [mailto:mj@digicool.com] Inviato: mercoledì 14 marzo 2001 10.50 A: Jeff Griffith Cc: zope@zope.org Oggetto: Re: [Zope] Natural XML Parsing On Tue, Mar 13, 2001 at 06:46:42PM -0500, Jeff Griffith wrote:
Hey All,
While messing around with XML I became really frustrated at how unnatural it seemed to extract data out of documents. I ended up writing my own python class to do exactly what felt natural. The problem is the entire time I kept telling myself "this code has to already exist somewhere" I just could never find it.
So if anyone is interested take a look at how this class works and tell me if 1) this seems useful 2) this is already supported by someone else
A brief example of how it is used --------------
< collection > < comic issue="1"> < author > Stan Lee < /author > < /comic > < /collection >
can be accessed as
collection.comic.author.TEXT collection.comic.ATTR('issue') --------------- a more complete write-up w/source is available at http://www.people.hbs.edu/jgriffith/simplexmlobject.html
Have you looked at ParsedXML? http://www.zope.org/Wikis/DevSite/Projects/ParsedXML/Releases It is a fully DOM level 2 compliant XML object. It'll let you access your XML via DOM calls. They may seem less convenient than your example, but will cover the cases where you have more than one 'comic' element. Your example could translate to: xmlDoc.documentElement.childNodes[0].childNodes[0].childNodes[0] xmlDoc.documentElement.childNodes[0].getAttribute('issue') or by using the tagname the first example would become: comic = xmlDoc.documentElement.getElementsByTagName('comic')[0] authorName = comic.getElementsByTagName('author')[0].getChildNodes(0) In future versions, XML id support is planned; if you have a DTD that tells the parser what attributes are Id's, you can traverse the tree using Id attributes for the same effect. Then you can use a document like: <collection> <comic issue="1" id="first_issue"> <author>Stan Lee</author> </comic> </collection> and code like: comic = xmlDoc.getElementById('first_issue') authorName = comic.getElementsByTagName('author')[0].getChildNodes(0) Hope this helps! -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ --------------------------------------------- _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I doubt whether they are going to abandon the Win32, but they are developing on *nix systems. I'd imagine they will getting it working on Win32 asap. But not before. ;) Phil phil.harris@zweb.co.uk ----- Original Message ----- From: "Zanotti Michele" <Zanotti@az.aziendasanitaria.trentino.it> To: <zope@zope.org> Sent: Wednesday, March 14, 2001 10:42 AM Subject: [Zope] XML Parsed for all platforms?
Ciao, I see that XMLParsed 0.1 b3 is only for generic Unix-like platform, while 0.1 b1 and b2 are for all platforms. Do you know if XMLParsed developers want to abandon Win platform? Thanks, Michele
-----Messaggio originale----- Da: Martijn Pieters [mailto:mj@digicool.com] Inviato: mercoledì 14 marzo 2001 10.50 A: Jeff Griffith Cc: zope@zope.org Oggetto: Re: [Zope] Natural XML Parsing
On Tue, Mar 13, 2001 at 06:46:42PM -0500, Jeff Griffith wrote:
Hey All,
While messing around with XML I became really frustrated at how unnatural it seemed to extract data out of documents. I ended up writing my own python class to do exactly what felt natural. The problem is the entire time I kept telling myself "this code has to already exist somewhere" I just could never find it.
So if anyone is interested take a look at how this class works and tell me if 1) this seems useful 2) this is already supported by someone else
A brief example of how it is used --------------
< collection > < comic issue="1"> < author > Stan Lee < /author > < /comic > < /collection >
can be accessed as
collection.comic.author.TEXT collection.comic.ATTR('issue') --------------- a more complete write-up w/source is available at http://www.people.hbs.edu/jgriffith/simplexmlobject.html
Have you looked at ParsedXML?
http://www.zope.org/Wikis/DevSite/Projects/ParsedXML/Releases
It is a fully DOM level 2 compliant XML object. It'll let you access your XML via DOM calls. They may seem less convenient than your example, but will cover the cases where you have more than one 'comic' element.
Your example could translate to:
xmlDoc.documentElement.childNodes[0].childNodes[0].childNodes[0] xmlDoc.documentElement.childNodes[0].getAttribute('issue')
or by using the tagname the first example would become:
comic = xmlDoc.documentElement.getElementsByTagName('comic')[0] authorName = comic.getElementsByTagName('author')[0].getChildNodes(0)
In future versions, XML id support is planned; if you have a DTD that tells the parser what attributes are Id's, you can traverse the tree using Id attributes for the same effect. Then you can use a document like:
<collection> <comic issue="1" id="first_issue"> <author>Stan Lee</author> </comic> </collection>
and code like:
comic = xmlDoc.getElementById('first_issue') authorName = comic.getElementsByTagName('author')[0].getChildNodes(0)
Hope this helps!
-- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Wed, Mar 14, 2001 at 11:42:21AM +0100, Zanotti Michele wrote:
I see that XMLParsed 0.1 b3 is only for generic Unix-like platform, while 0.1 b1 and b2 are for all platforms. Do you know if XMLParsed developers want to abandon Win platform?
Actually, that may be a mistake; b3 is also ment for all platforms, but I know that karl hasn't yet managed to get a Windows development environment running for him to compile a Win32 version. We will certainly not abandon the Windows platform; if anyone can assist us with compilation of the Product on the Windows platform however, I am sure it would help matters :) -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
participants (3)
-
Martijn Pieters -
Phil Harris -
Zanotti Michele