[XML-SIG] Builder doesn't quote ' or " properly?

Anthony Baxter anthony@interlink.com.au
Fri, 12 May 2000 23:33:37 +1000


Just for confirmation, the following is bad behaviour by the Builder
code, right?

This code:
#-------------
from xml.dom.builder import Builder
b = Builder()
b.startElement("blob");  b.text("\012")
b.startElement("line", {"text":"it's..."})
b.endElement("line");  b.text("\012")
b.startElement("line", {"text":"doug & dinsdale"})
b.endElement("line");  b.text("\012")
b.startElement("line", {"text":'"spiny" norman'})
b.endElement("line");  b.text("\012")
b.endElement("blob")
print b.document.toxml()
#-------------

produces this output
#-------------
<?xml version="1.0"?>
<blob>
<line text='it's...' />
<line text='doug &amp; dinsdale' />
<line text='"spiny" norman' />
</blob>
#-------------

Note that it quotes the &, but not the ' or the ".

Suggestions? Should I be quoting this by hand? Should I be hunting into
the code to find out where it's getting it wrong?

ta,
Anthony
--
Anthony Baxter     <anthony@interlink.com.au>
It's never too late to have a happy childhood.