#Импорт XML файлов
import xml.etree.ElementTree as xml
import os
import xml.etree.cElementTree as ET
import xml.etree.ElementTree as ET
def parseXML(xml_file):
tree=ET.ElementTree(file=xml_file)
print(tree.getroot())
root=tree.getroot()
print("tag=%s, attrib=%s" % (root.tag, root.attrib))
for child in root:
print('child tag',child.tag, child.attrib)
if child.tag == "appointment":
for step_child in child:
print(step_child.tag)
for child in root.iter('BasicBlock'):
for BasicBlock in child.iter('BasicBlock'):
print('BasicBlock', child.tag, child.attrib)
#Выводит тег Data
for child in root.iter('data'):
for data in child.iter('data'):
print('data', child.tag, child.attrib)
for child in root.iter('ExplicitLink'):
for ExplicitLink in child.iter('ExplicitLink'):
print('ExplicitLink', child.tag, child.attrib)
with open('filename.txt', 'w') as fo:
fo.write(sss.Xml)
path_to_program = r"C:\Users\Name PC\Desktop\Prractic"
path_to_XML = os.path.join(path_to_program, 'sss.Xml')
parseXML(path_to_XML)