1
私はElementTreeのXMLファイルXML宣言をXMLファイルに書き込む方法は?
for i in range(len(lang_list)):
body = ET.SubElement(root, "body")
body.set("lang", lang_list[i])
# body.text = text_list[i] + " " + common_text
body.text =unescape(escape('<![CDATA[')) + text_list[i] + " " + common_text + unescape(escape(']]>'))
body.tail = "\n\t"
outpath = os.getcwd()
file = outpath + "\\test.xml"
tree.write(file, xml_declaration=True)
を書く使用して、現在の午前しかし、XML宣言をそこに持っているような
DOCTYPE電子メールテンプレートPUBLIC「 -// yourcompany、Inc.//DTD電子メールテンプレート// EN "" email-template.dtd ">
この情報をXMLファイルに書き込む方法はありますか?
であなたの最後の行に
を交換することです。あなたは私の答え[ここ](https://gist.github.com/larsks/de0d32d3796609cd856da7b95e7e4808)を見ることができます。 – larsks