[Tutor] xml stuff
Furmanek, Greg
Greg.Furmanek@hit.cendant.com
Thu, 8 Mar 2001 11:30:37 -0500
I seem to have problem with xml.
When I tried to run some examples the
interpreter is giving me a message
Traceback (most recent call last):
File "try1.py", line 28, in ?
import pyexpat
ImportError: No module named pyexpat
I am using py 2.0 On Sun.
is there a problem with xml libs in this
version???
some code.
*************************************** START **************************
from xml.sax import saxutils
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces
import pyexpat
string = """
<collection>
<comic title="Sandman" number='62'>
<writer>Neil Gaiman</writer>
<penciller pages='1-9,18-24'>Glyn Dillon</penciller>
<penciller pages="10-17">Charles Vess</penciller>
</comic>
</collection>
"""
# ............................... FUNCTIONS
...............................
def main():
# Create a parser
parser = make_parser()
# Tell the parser we are not interested in XML namespaces
parser.setFeature(feature_namespaces, 0)
# Create the handler
dh = FindIssue('Sandman', '62')
# Tell the parser to use our handler
parser.setContentHandler(dh)
# Parse the input
parser.parse(file)
# ................................ CLASSES
................................
# ............................ EXECUTION START
............................
if __name__ == "__main__":
main()
*************************************** START **************************
Grzegorz Furmanek
Furmanek.Greg@hit.cendant.com
----------------------------------------------------------
Three Mile Island '79 Chernobyl '86 Windows '00 (1900)
"The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message
and its attachments could have been infected during transmission. By
reading the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments."