[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>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Benjamin<BR>
<BR>
------------------------ Cut here<BR>
test_data =3D &quot;&quot;&quot;&lt;?xml version=3D&quot;1.0&quot; ?&gt;<BR>
&lt;multistatus&gt;<BR>
 &nbsp;&lt;response&gt;<BR>
 &nbsp;&nbsp;&nbsp;<BR>
&lt;href&gt;<FONT COLOR=3D"#0000FF"><U>http://xww.psg-techservices.world.xero=
x.com/docushare/Collection-22<BR>
&lt;/href</U></FONT>&gt;<BR>
 &nbsp;&nbsp;&nbsp;&lt;propstat&gt;<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&lt;prop&gt;<BR>
 &nbsp;&lt;displayname&gt;TSA - Material in Transit&lt;/displayname&gt;<BR>
 &nbsp;&lt;displayname&gt;TSA - Material in Transit&lt;/displayname&gt;<BR>
 &nbsp;&lt;summary&gt;(Temporary Files)&lt;/summary&gt;<BR>
&lt;entityowner&gt;&lt;dsref handle=3D&quot;User-2&quot;&gt;&lt;displayname&g=
t;Benjamin <BR>
Schollnick&lt;/displayname&gt;<BR>
&lt;username&gt;admin&lt;/username&gt;&lt;/dsref&gt;&lt;/entityowner&gt;<BR=
>
&lt;parents&gt;<BR>
&lt;dsref handle=3D&quot;Collection-10&quot;&gt;&lt;displayname&gt;&lt;![CDAT=
A[TSE - Test Support &amp; <BR>
Automation Folder]]&gt;&lt;/displayname&gt;&lt;/dsref&gt;<BR>
&lt;/parents&gt;<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&lt;/prop&gt;<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&lt;status&gt;HTTP/1.1 200 OK&lt;/status&gt;&quot;=
&quot;&quot;<BR>
<BR>
#from xml.dom.minidom import parse, parseString<BR>
#dom =3D parseString (test_data)<BR>
#print dom.getElementsByTagName (&quot;parents&quot;)<BR>
#print dom.getElementsByTagName (&quot;handle&quot;)<BR>
<BR>
import xml.parsers.expat<BR>
<BR>
def &nbsp;&nbsp;&nbsp;&nbsp;start_element(name, attrs):<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;Start :&quot;,name, =
&quot;\t\tattrs: &quot;,attrs<BR>
<BR>
def &nbsp;&nbsp;&nbsp;&nbsp;end_element(name):<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;End :&quot;,name<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
def &nbsp;&nbsp;&nbsp;&nbsp;char_data (data):<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;Character : &quot;, =
repr(data)<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass<BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
parser =3D xml.parsers.expat.ParserCreate()<BR>
parser.EndElementHandler &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D end_el=
ement<BR>
parser.StartElementHandler &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D start_element<BR=
>
print &quot;XML.Parsers.Expat \n------------------------------------------&=
quot;<BR>
parser.Parse (test_data)<BR>
#print &quot;xml.sax \n------------------------------------------&quot;<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--