XML Declaration standalone=“yes” lxml

前端 未结 5 1225
暗喜
暗喜 2020-12-20 13:01

I have an xml I am parsing, making some changes and saving out to a new file. It has the declaration

5条回答
  •  渐次进展
    2020-12-20 13:07

    If you want to show the standalone='no' argument in your XML header, you have to set it to False instead of 'no'. Just like this:

    etree.tostring(tree, pretty_print = True, xml_declaration = True, encoding='UTF-8', standalone=False)
    

    If not, standalone will be set to 'yes' by default.

提交回复
热议问题