Editing XML as a dictionary in python?

前端 未结 8 1061
深忆病人
深忆病人 2020-12-31 18:11

I\'m trying to generate customized xml files from a template xml file in python.

Conceptually, I want to read in the template xml, remove some elements, change some

8条回答
  •  礼貌的吻别
    2020-12-31 18:16

    most direct way to me :

    root        = ET.parse(xh)
    data        = root.getroot()
    xdic        = {}
    if data > None:
        for part in data.getchildren():
            xdic[part.tag] = part.text
    

提交回复
热议问题