parse xml string in a socket server

Peter Hansen peter at engcorp.com
Mon Feb 24 16:59:52 EST 2003


Sephiroth *TMM* wrote:
> 
> Hi to all,
> i'm a newbie in python and i've this problem..
> 
> i have no problem parsing an xml string with for example:
> 
> xmlstring = "<?xml version=\"1.0\"><root><message>hi</message></root>"
> from xml.dom import minidom
> print "parsing %s" % xmlstring
> doc = minidom.parseString(xmlstring)
> 
> but if i put this in a function of a socket server which receive the xmlstring from a client ti gives me alway an error, "invalid
> token".
> I don't know why, the print give me exactly the same string but the parseString failed anyway

Please always cut and paste the output of your session including the precise
error message and traceback, rather than paraphrasing.  Usually this is
much more effective at helping us find the problem.

In this case, I can see at least one problem: your XML processing
instruction is incorrect, as it does not end with the proper closing
sequence of "?>".  Try '<?xml version="1.0"?>' instead.  Not sure
this will help, but it's at least the first problem.

-Peter




More information about the Python-list mailing list