4
我有一個示例XML文件是這樣的:如何在Python 3中將元素的內容包裝到XML標記中?
<root>
She
<opt>went</opt>
<opt>didn't go</opt>
to school.
</root>
我想創建一個命名的子元素,並把所有的內容進去。也就是說,
<root>
<sentence>
She
<opt>went</opt>
<opt>didn't go</opt>
to school.
</sentence>
</root>
我知道熱,以與ElementTree的或LXML一個子元素,但我不知道該怎樣從「她」選擇主意「shools。」一次全部。
import lxml.etree as ET
ET.SubElement(root, 'sentence')
I'm lost...