


Работа с xml файлами в python
Помогите пожалуйста решить проблему . У меня есть файл формата xml с именем menu.xml со следующим содержимым:
breakfast burritos>/item>
pancakes
hamburger
spagetti
Мне нужно проанализировать этот файл используя библиотеку ElementTree:
import xml.etree.ElementTree as et
tree = et.ElementTree(file='menu.xml')
root = tree.getroot()
root.tag
for child in root:
print('tag:',child.tag,'attributes:',child.attrib)
for grandchild in child:
print('\ttag:',grandchild.tag, 'attributes:',grandchild.attrib)
len(root)
len(root[0])
Выходит ошибка в Pycharm
FileNotFoundError: [Errno 2] No such file or directory: 'menu.xml'
или такая в VisualStudiocode
D:\python\xml>C:/Users/User/AppData/Local/Programs/Python/Python37-32/python.exe d:/python/xml/Untitled-1.py
Traceback (most recent call last):
File "d:/python/xml/Untitled-1.py", line 2, in
tree = et.ElementTree(file='menu.xml')
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\xml\etree\ElementTree.py", line 558, in __init__
self.parse(file)
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\xml\etree\ElementTree.py", line 598, in parse
self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: mismatched tag: line 6, column 6
Я помочь не могу, но хочу сказать, что тебе наврятли кто-нибудь ответит