已解决xmL.parsers.expat.ExpatError: no eLement found: Line 1, column 0

已解决(Python读取xml文件报错)xmL.parsers.expat.ExpatError: no eLement found: Line 1, column 0




文章目录

  • 报错代码
  • 报错翻译
  • 报错原因
  • 解决方法




报错代码


粉丝群里的一个小伙伴想用Python读取xml文件报错:

已解决xmL.parsers.expat.ExpatError: no eLement found: Line 1, column 0_第1张图片

报错信息

xmL.parsers.expat.ExpatError: no eLement found: Line 1, column 0


报错翻译


报错信息翻译

xml.解析器.报错:未找到元素:第1行第0列



报错原因


报错原因:如果xml文件不以 开头,会报这个错误。



解决方法


修改改为正确xml文件格式,如:

<?xml version="1.0” encoding=' "UTF-8" standalone=" no”?>
<collection shelf="New Arrivals">
	<class className="1班">
	   <code>2022001</code>
	   <number>10</number>
	   <teacher>小白</teacher>
	</class>
	<class className="2班">
	   <code>2022002</code>
	   <number>20</number>
	   <teacher>小红</teacher>
	</class>
	<class className="3班">
	   <code>2022003</code>
	   <number>30</number>
	   <teacher>小黑</teacher>
	</class>
</collection>

你可能感兴趣的:(《告别Bug》,xml,python)