Re: [Zope] how to read xml file in a python script
Hi Andreas, Thanks for replying to me. I checked out the python documentation and I followed up with this good hands on article about parsing XML in Python (http://www.devarticles.com/art/1/383/3) In the article, they mention one way to parse xml using the sax parser by importing this module: from xml.sax import make_parser and using this command: parser.parse(open('playerStats.xml')) But when I try to do this in my zope python script, I get Error Value: import of "xml.sax" is unauthorized Also I read that the open command is not allowed in zope. And so I am afraid I am still stick with my original problem: I have an xml document under zope and I would like to parse it and extract its content with a python script. I would like to do this under the context of zope. I know there is lots of documentation on how to use xml under python. But how do I use read xml under zope? Is it different? Thanks again for any input pvu
From: Andreas Jung <lists@andreas-jung.com> Reply-To: Andreas Jung <lists@andreas-jung.com> To: vupt vupt <vuptme@hotmail.com>, zope@zope.org Subject: Re: [Zope] how to read xml file in a python script Date: Wed, 05 Nov 2003 14:32:19 +0100
Read the Python Library Reference. THere is enough documentation on Python+XML.
-aj
--On Mittwoch, 5. November 2003 13:26 Uhr +0000 vupt vupt <vuptme@hotmail.com> wrote:
Hi,
I am new to Zope and hope someone can help me with an xml task.
I have created an Xml file using the XMLKit product. Now I would like to create a python script to parse the XML file to get information from it. How do I do this?
If someone can point me to some examples or give some examples of how to do this, I would very appreciate it.
thanks in advance.
pvu
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin. msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
_______________________________________________ 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 )
_________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=http%3a%2f%2fjoin....
Python scripts in Zope are restricted for security reasons. You'll need to do your XML processing using External Methods (python scripts, but not subject to the same security restrictions) or Products (python extensions to Zope). When you set up the Python XML tools, remember to install them into the Python you use to run Zope, not elsewhere. You may want to consider using the PyRXP parser from ReportLabs which is fast, stable, and very python friendly. On Wed, 5 Nov 2003, vupt vupt wrote:
Hi Andreas,
Thanks for replying to me.
I checked out the python documentation and I followed up with this good hands on article about parsing XML in Python (http://www.devarticles.com/art/1/383/3)
In the article, they mention one way to parse xml using the sax parser by importing this module: from xml.sax import make_parser
and using this command: parser.parse(open('playerStats.xml'))
But when I try to do this in my zope python script, I get Error Value: import of "xml.sax" is unauthorized
Also I read that the open command is not allowed in zope.
And so I am afraid I am still stick with my original problem: I have an xml document under zope and I would like to parse it and extract its content with a python script. I would like to do this under the context of zope.
I know there is lots of documentation on how to use xml under python. But how do I use read xml under zope? Is it different?
Thanks again for any input
pvu
From: Andreas Jung <lists@andreas-jung.com> Reply-To: Andreas Jung <lists@andreas-jung.com> To: vupt vupt <vuptme@hotmail.com>, zope@zope.org Subject: Re: [Zope] how to read xml file in a python script Date: Wed, 05 Nov 2003 14:32:19 +0100
Read the Python Library Reference. THere is enough documentation on Python+XML.
-aj
--On Mittwoch, 5. November 2003 13:26 Uhr +0000 vupt vupt <vuptme@hotmail.com> wrote:
Hi,
I am new to Zope and hope someone can help me with an xml task.
I have created an Xml file using the XMLKit product. Now I would like to create a python script to parse the XML file to get information from it. How do I do this?
If someone can point me to some examples or give some examples of how to do this, I would very appreciate it.
thanks in advance.
pvu
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin. msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
_______________________________________________ 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 )
_________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=http%3a%2f%2fjoin....
_______________________________________________ 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 )
And so I am afraid I am still stick with my original problem: I have an xml document under zope and I would like to parse it and extract its content with a python script. I would like to do this under the context of zope.
You've heard about the restrictions on TTW code. Use an external method. Or... There are Zope products to help with this. There is/used to be a ParsedXML product and several others to make XML available looking like Zope objects or in some other reasonable way. If you want to do straight Python, there's SAX [http://www.saxproject.org/] and DOM parsers. Both are pretty easy, but it depends on what you want to do which to use. E.g. for absolute simplicity of implementation, Python's MiniDOM can't be beat. For large datasets, you'll want to go with SAX. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
participants (3)
-
Dennis Allison -
J. Cameron Cooper -
vupt vupt