[XML-SIG] well-formed xml
Mark McEahern
marklists at mceahern.com
Fri Sep 27 15:31:10 EDT 2002
[Mike Rovner]
> IIRC, double quotes are the must:
> s = '<a href="http://google.com/search?hl=en&q=foobar">search</a>'
Thanks for the reply. It seems to be the ampersand:
from xml.dom import minidom
s = "<a href='http://google.com/search?hl=en&q=foobar'>search</a>"
s2 = s.replace("&", "&")
for x in (s, s2):
try:
doc = minidom.parseString(x)
except Exception, e:
print "Failed: %s" % x
else:
print "Succeeded: %s" % x
Output:
Failed: <a href='http://google.com/search?hl=en&q=foobar'>search</a>
Succeeded: <a href='http://google.com/search?hl=en&q=foobar'>search</a>
// m
More information about the Python-list
mailing list