How to quote XML to get the string with quoted control characters in python?
Source string:
<root namespace="value" id="guid">
<chi开发者_如何学JAVAld name="child1">Content</child>
</root>
Result string:
<root namespace=\"value\" id=\"guid\">\n <child name=\"child1\">Content<\/child><\/root>
You can find information about how to escape/unscape xml entities in the python.org
wiki. In particular, there's a section about quoting attributes with xml.sax.saxutils.quoteattr
which seems to be what you're looking for.
精彩评论