Estoy aprendiendo lo básico de Python con el libro "Python Programming Fundamentals" y tengo un problema con un error que no doy solucinado.
Estoy usando el debbuger Wing 101 8, y quería parsear el siguiente código XML:
<? xml version =" 1 . 0 " encoding =" UTF -8 " standalone =" no " ? >
< GraphicsCommands >
< Command color =" #804000 " > BeginFill </ Command >
< Command x=" 299.0 " y=" -45.0 " width =" 1 . 0 "
color =" #804000 " >GoTo </ Command >
< Command x=" 302.0 " y=" -297.0 " width =" 1.0 "
color =" #804000 " >GoTo </ Command >
< Command x=" -301.0 " y=" -298.0 " width =" 1.0 "
color =" #804000 " >GoTo </ Command >
< Command x=" -300.0 " y=" -53.0 " width =" 1 . 0 "
color =" #804000 " >GoTo </ Command >
< Command > EndFill </ Command >
< Command color =" #004080 " > BeginFill </ Command >
< Command x=" -300.0 " y=" 300.0 " width =" 1.0 "
color =" #004080 " >GoTo </ Command >
< Command x=" 299.0 " y=" 299.0 " width =" 1 . 0 "
color =" #004080 " >GoTo </ Command >
< Command x=" 300.0 " y=" -45.0 " width =" 1 . 0 "
color =" #004080 " >GoTo </ Command >
< Command > EndFill </ Command >
< Command > PenUp </ Command >
< Command x=" 0 . 0 " y=" 0 . 0 " width =" 1 . 0 "
color =" #000000 " >GoTo </ Command >
< Command > PenDown </ Command >
< Command radius =" 10.0 " width =" 10 "
color ="# ffffff " > Circle </ Command >
< Command radius =" 20.0 " width =" 10 "
color ="# ff0080 " > Circle </ Command >
< Command x=" 2 . 0 " y=" -4.0 " width =" 10.0 "
color ="# ff0080 " >GoTo </ Command >
< Command x=" 2 . 0 " y=" -5.0 " width =" 10.0 "
color ="# ff0080 " >GoTo </ Command >
< Command x=" 2 . 0 " y=" -6.0 " width =" 10.0 "
color ="# ff0080 " >GoTo </ Command >
</ GraphicsCommands >
Para ello he usado el siguiente código:
from xml.dom import minidom
xmldoc = minidom.parse('flowerandbg.xml')
Y tras ejecutar el programa he obtenido el siguiente error:
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
Type "help", "copyright", "credits" or "license" for more information.
[evaluate ensucio.py]
Traceback (most recent call last):
File "E:\ARCHIVOS APRENDIZAJE PYTHON\ensucio.py", line 3, in <module>
pass
File "C:\Users\Equipo\AppData\Local\Programs\Python\Python310\Lib\xml\dom\minidom.py", line 1988, in parse
return expatbuilder.parse(file)
File "C:\Users\Equipo\AppData\Local\Programs\Python\Python310\Lib\xml\dom\expatbuilder.py", line 911, in parse
result = builder.parseFile(fp)
File "C:\Users\Equipo\AppData\Local\Programs\Python\Python310\Lib\xml\dom\expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 2
He estado mirando las funciones de las librerías que usa y no entiendo donde está el problema puesto que son librerias que ya vienen preinstaladas con Python y no simplemento he querido parsear un archivo que tengo guardado. Cuando me salta el error se abre la librería "expatbilder.py" y me identifica el error en la siguiente línea:
¿Alguien me puede ayudar a encontrar el porqué surge este error?
A continuación muestro una foto de como valido en xmlvalidation.com el código XML y en la siguiente el mismo error que se genera.