[XML-SIG] Python/XML HOWTO

Lars Marius Garshol larsga@ifi.uio.no
27 May 1999 12:48:32 +0200


* Paul Chung Chee Soong
|
|  parser.parseFile('collection.xml')          # 4
|
| [...]
|
| Next in # 4, I got problem again. In your example, your parameter is
| a file. What is the 'file' represents? I thought it was a xml file
| but it isn't right??
 
* Lars Marius Garshol
|
| It's the name of an XML file. If you want to push an XML document as a
| string ('<root><title>My title</title> ...</root>') you can use the
| parser.reset(), parser.feed('...') and parser.close() methods.

Sorry, I was a bit quick here and got it wrong. The SAX parser class
has two parse methods:

  - parse(URL)
  - parseFile(file-object)

So parse takes the file name of an XML document (but it can be a URL)
and parseFile takes a file-like object (like what is returned by
urllib.urlopen and open).

Sorry about that.

--Lars M.