[XML-SIG] XML problem with Python v2.0?? programmer error?
Benjamin Schollnick
junkster@rochester.rr.com
Sun, 24 Jun 2001 12:05:32 -0400
> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--MS_Mac_OE_3076229132_143460_MIME_Part
Content-type: text/plain; charset="US-ASCII"
Content-transfer-encoding: 7bit
I'm attempting to finish a pseudo webdav interface class...
The only problem is that the XML results I'm receiving aren't being
handled correctly....
This test application seems to be ignoring several of the entries from
the captured stream.
The XML looks AOK to me, but I haven't written XML before, and I'm not
sure if I'm reading this correctly.
Could anyone chime up, and point out any errors that I may have caused?
- Benjamin
------------------------ Cut here
test_data = """<?xml version="1.0" ?>
<multistatus>
<response>
<href>http://xww.psg-techservices.world.xerox.com/docushare/Collection-22
</href>
<propstat>
<prop>
<displayname>TSA - Material in Transit</displayname>
<displayname>TSA - Material in Transit</displayname>
<summary>(Temporary Files)</summary>
<entityowner><dsref handle="User-2"><displayname>Benjamin
Schollnick</displayname>
<username>admin</username></dsref></entityowner>
<parents>
<dsref handle="Collection-10"><displayname><![CDATA[TSE - Test Support &
Automation Folder]]></displayname></dsref>
</parents>
</prop>
<status>HTTP/1.1 200 OK</status>"""
#from xml.dom.minidom import parse, parseString
#dom = parseString (test_data)
#print dom.getElementsByTagName ("parents")
#print dom.getElementsByTagName ("handle")
import xml.parsers.expat
def start_element(name, attrs):
print "Start :",name, "\t\tattrs: ",attrs
def end_element(name):
print "End :",name
pass
def char_data (data):
print "Character : ", repr(data)
pass
parser = xml.parsers.expat.ParserCreate()
parser.EndElementHandler = end_element
parser.StartElementHandler = start_element
print "XML.Parsers.Expat \n------------------------------------------"
parser.Parse (test_data)
#print "xml.sax \n------------------------------------------"
#import xml.sax
#dparser2 = xml.sax.make_parser()
#print xml.sax.parseString(test_data, dparser2)
--MS_Mac_OE_3076229132_143460_MIME_Part
Content-type: text/html; charset="US-ASCII"
Content-transfer-encoding: quoted-printable
<HTML>
<HEAD>
<TITLE>XML problem with Python v2.0?? programmer error?</TITLE>
</HEAD>
<BODY>
<TT>I'm attempting to finish a pseudo webdav interface class...<BR>
<BR>
The only problem is that the XML results I'm receiving aren't being <BR>
handled correctly....<BR>
<BR>
This test application seems to be ignoring several of the entries from <BR>
the captured stream.<BR>
<BR>
The XML looks AOK to me, but I haven't written XML before, and I'm not <BR>
sure if I'm reading this correctly.<BR>
<BR>
Could anyone chime up, and point out any errors that I may have caused?<BR>
<BR>
- Benjamin<BR>
<BR>
------------------------ Cut here<BR>
test_data =3D """<?xml version=3D"1.0" ?><BR>
<multistatus><BR>
<response><BR>
<BR>
<href><FONT COLOR=3D"#0000FF"><U>http://xww.psg-techservices.world.xero=
x.com/docushare/Collection-22<BR>
</href</U></FONT>><BR>
<propstat><BR>
<prop><BR>
<displayname>TSA - Material in Transit</displayname><BR>
<displayname>TSA - Material in Transit</displayname><BR>
<summary>(Temporary Files)</summary><BR>
<entityowner><dsref handle=3D"User-2"><displayname&g=
t;Benjamin <BR>
Schollnick</displayname><BR>
<username>admin</username></dsref></entityowner><BR=
>
<parents><BR>
<dsref handle=3D"Collection-10"><displayname><![CDAT=
A[TSE - Test Support & <BR>
Automation Folder]]></displayname></dsref><BR>
</parents><BR>
</prop><BR>
<status>HTTP/1.1 200 OK</status>"=
""<BR>
<BR>
#from xml.dom.minidom import parse, parseString<BR>
#dom =3D parseString (test_data)<BR>
#print dom.getElementsByTagName ("parents")<BR>
#print dom.getElementsByTagName ("handle")<BR>
<BR>
import xml.parsers.expat<BR>
<BR>
def start_element(name, attrs):<BR>
print "Start :",name, =
"\t\tattrs: ",attrs<BR>
<BR>
def end_element(name):<BR>
print "End :",name<BR>
pass<BR>
<BR>
def char_data (data):<BR>
print "Character : ", =
repr(data)<BR>
pass<BR>
<BR>
parser =3D xml.parsers.expat.ParserCreate()<BR>
parser.EndElementHandler =3D end_el=
ement<BR>
parser.StartElementHandler =3D start_element<BR=
>
print "XML.Parsers.Expat \n------------------------------------------&=
quot;<BR>
parser.Parse (test_data)<BR>
#print "xml.sax \n------------------------------------------"<BR>
<BR>
#import xml.sax<BR>
#dparser2 =3D xml.sax.make_parser()<BR>
#print xml.sax.parseString(test_data, dparser2)<BR>
</TT>
</BODY>
</HTML>
--MS_Mac_OE_3076229132_143460_MIME_Part--