#递归遍历xml文件中的tag,value,desc属性值#3
def etree(filePath, root):
name, suf = os.path.splitext(filePath) # =>文件名,文件后缀
for child in root:
if (root.getchildren() is None):
break
else:
with open(name+".txt",'a',encoding="utf-8") as createfilePath:
createfilePath.writelines(str(child.tag)+"**"+str(child.get("value"))+"**"+str(child.get("desc"))+"\n")
print("tag--"+str(child.tag), "value--"+str(child.get("value")),"desc--"+str(child.get("desc")))
etree(filePath,child)#递归调用遍历子节点
递归遍历xml文件中的tag,value,desc属性值#3
最新推荐文章于 2024-01-26 23:35:32 发布