root of the xml file is giving as NONE why?

白昼怎懂夜的黑 提交于 2019-12-02 07:46:36

The following code is enough. You don't need to open the file at beginning. ET.parse will do it for you if you provide the correct path.

In your code you import the library as ET and then reassign the same variable by opening the file. So ET.parse() referes to your file object not to your elementtree library.

import xml.etree.ElementTree as ET

tree= ET.parse('note.xml')
root= tree.getroot()
print(root.tag) # to print root
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!