Trouble with Parsing XML

Benjamin Schollnick junkster at rochester.rr.com
Wed Jun 6 22:41:04 CEST 2001


Folks,

   I'm running into a slight problem here with a XML reply from a 
semi-WEBDAV server....(A Docushare v2.1 server)

   This is using Python v2.0.....

----------------

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>
  <summary>(Temporary Files)</summary>
<entityowner><dsref handle="User-2"><displayname>Benjamin 
Schollnick</displayname><username>admin</username></dsref></entityowner>
<parents>
<dsref handle="Collection-10">"""
 

#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()

-----

Here's the XML code that I was trying to use.... And I decided to try 
EXPAT...

EXPAT does give me a few of the objects data back, but not all of them.

Can anyone verify that EXPAT is operating properly?  I'm assuming this 
is a Programmer (my) error, but I'm not familiar enough with EXPAT to 
decide on what is the problem.

      - Benjamin



More information about the Python-list mailing list