Handling quotes in xml.dom text nodes

Chaim Krause chaim at chaim.com
Tue Apr 13 17:26:26 CEST 2010


I am building a web page (HTML 4.01 Transitional) using
xml.dom.minidom. I have created a <script> node and I have added the
Javascript as a child text node. The issue is that the Javascript
includes quotes that I want to survive when I write the XML to a file.
The issue for me is that they are translated into ".

I know that this is the expected behavior, but I cannot find a manner
to override this behavior to have the quotes survive.

For example, what I want:
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

What I get:
var map = new
google.maps.Map(document.getElementById("map_canvas"),
myOptions);

What do you suggest I do to get the desired behavior without rewriting
xml.dom? Or is overriding the method the best way to go?



More information about the Python-list mailing list