开发者

XML quoting in Python

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜