Newbie Python+XML Question

Jeff Layton laytonjb at bellsouth.net
Tue Mar 5 18:49:17 EST 2002


Hello,

   I'm fairly new to Python and I'm trying to understand and
run some else's code that uses XML (SAX). Here's the top
part of the code:

#

import socket
import getopt
import string
import xml.sax
#import xml.sax.saxutils
from xml.sax import saxutils
import sys


class XmlHandler(saxutils.DefultHandler):

        def __init__(self, argv, machines=[]):
                saxutils.DefultHandler.__init__(self)
                self.info = {}
                self.hostname = ''
                self.max_hostname_len = 0
                self.metrics = {}
                self.machines = machines


I tried following the SAX example at:

http://py-howto.sourceforge.net/xml-howto/xml-howto.html

to understand what the author was doing. However,
when I run the script as follows, it dies on me.

% python2.1 testg.py
Traceback (most recent call last):
  File "testg.py", line 26, in ?
    class XmlHandler(saxutils.DefultHandler):
AttributeError: 'xml.sax.saxutils' module has no attribute 'DefultHandler'

   It looks like the SAX stuff is not getting imported correctly.
Does anyone feel like helping a lowly Newbie with this one?

TIA,

Jeff






More information about the Python-list mailing list