I have the following structure
<root>
<data>
<config>
CONFIGURATION
<config>
</data>
</root>
Run Code Online (Sandbox Code Playgroud)
使用 Python 的 ElementTree 模块,我想添加一个父元素来<config>标记为
<root>
<data>
<type>
<config>
CONFIGURATION
<config>
</type>
</data>
</root>
Run Code Online (Sandbox Code Playgroud)
此外,xml 文件可能在其他地方有其他配置标签,但我只对出现在数据标签下的那些感兴趣。