lxml を使用して、ルート要素の前に処理命令を追加したり、lxml を使用してルート要素の後に PI を追加したりするにはどうすればよいですか。
現在、次の例は機能しません。
from lxml import etree
root = etree.XML("<ROOT/>")
root.addprevious(etree.ProcessingInstruction("foo"))
print(etree.tounicode(root))
私は得る:
<ROOT/>
それ以外の:
<?foo?><ROOT/>