[Fedora-suds-list] Invalid token with string, OK as file

Joshua J. Kugler joshua at eeinternet.com
Tue Mar 2 22:45:28 UTC 2010


I'm trying out suds (0.4 trunk) and getting a weird behavior with the 
result.  If I pass the result of a call into a sax parser, I get a 'not 
well formed (invalid token)' error.  If I save that same result to a 
file, then pass that file to the parser, it works.  If I read that 
string from the file, and pass it to the parser, it works.

Any ideas?

Here's a short script showing the problem.

#!/usr/bin/python

import os
import suds

url = 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl'
client = suds.client.Client(url)

# print client

result = client.service.NDFDgenByDay(39.0000, -77.0000,
                                     2004-04-27, 1, '12 hourly')

print 'Result:\n', result

try:
    p = suds.sax.parser.Parser()
    print 'From string:', p.parse(string=result)
except Exception, e:
    print 'Oops:', e

open('nws_out.xml', 'w').write(result)

print 'From file:', repr(p.parse(file=open('nws_out.xml')))
print 'From file:', repr(p.parse(string=open('nws_out.xml').read()))

-- 
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0x14EA086E


More information about the suds mailing list