[XML-SIG] well-formed xml
Mark McEahern
marklists@mceahern.com
Fri, 27 Sep 2002 14:31:10 -0500
[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