how to open xml file element tree
import xml.etree.ElementTree as ET
tree = ET.parse('filename.xml') #this gets the file into a tree structure
tree_root = tree.getroot() #this gives us the root element of the file
how to open xml file element tree
import xml.etree.ElementTree as ET
tree = ET.parse('filename.xml') #this gets the file into a tree structure
tree_root = tree.getroot() #this gives us the root element of the file
how to read an xml file
import xmltodict as xtd
import os
xml_file_content = ""
catalog_dir = os.chdir('directory')
catalog_dir_array = os.listdir(catalog_dir)
if("nameOfFile.xml" in catalog_dir_array):
catalog_file_content = open("nameOfFile.xml", "r").read()
catalog_file_content_dict = xtd.parse(catalog_file_content)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us