Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
minidomを介してXML要素を作成しています:
ele = doc.createElement("ele") main.appendChild(ele) ele.attributes['name']= "bla"
しかし、要素は次のように見えます。
<ele name="bla"/>
そして私が欲しいのは:
<ele name="bla"></ele>
2 つの形式は同等です。本当に終了タグが必要な場合は、要素に空のテキスト ノードを追加します。
>>> ele = doc.createElement('ele') >>> ele.attributes['name']= "bla" >>> ele.appendChild(doc.createTextNode('')) >>> print ele.toxml() <ele name="bla"></ele>