python xml 错误

发布于 2024-08-20 12:43:35 字数 441 浏览 4 评论 0原文

我是 xml 新手。我正在尝试解析 xml 文件以从中提取数据,但当我调用 doc=minidom.parse('D:\\CONFIGRATION.xml') 时,它在消息下方显示错误...

xml.parsers.expat.ExpatError:not well-formed (invalid token): line 474, column 15

473 <Extras>
474    <extra Type>
475      jpg
476    </extra Type>
477    <extra Type>
478      psd
479    </extra Type>
480 </Extras>

有人可以帮我吗?什么是格式良好的 XML 文档?

提前致谢

I'm new to xml. I'm trying to parse an xml file to extract data from, but it shows the error below message when I call doc=minidom.parse('D:\\CONFIGRATION.xml') ...

xml.parsers.expat.ExpatError:not well-formed (invalid token): line 474, column 15

473 <Extras>
474    <extra Type>
475      jpg
476    </extra Type>
477    <extra Type>
478      psd
479    </extra Type>
480 </Extras>

Can anyone please help me? What is a well-formed XML document?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浊酒尽余欢 2024-08-27 12:43:35

您问“格式良好”是什么意思。这意味着 XML 符合标准。不“格式良好”意味着您使用了非法语法。在您的具体情况下,您的标签如下所示:

<@extra Type>

标签名称中不能有空格。您还有其他问题 - 您不能以 @ 开始标签,并且您的结束标签也是错误的。斜杠需要紧跟在 < 后面;

格式良好的 XML 的官方规范位于 W3C 网站。您的 xml 不符合规范。如果您需要有关文档的更多详细信息,您可以使用多种 xml 验证服务之一。使用您最喜欢的搜索引擎搜索“xmlvalidation”。

You ask what "well-formed" means. It means that the XML conforms to the standard. Not being "well-formed" means you've used illegal syntax. In your specific case you have a tag that looks like:

<@extra Type>

You can't have a space in your tag name. You have other problems as well -- you can't start a tag with @, and your closing tags are also wrong. The slash needs to immediately follow the <

The official specification for well-formed XML is on the W3C website. your xml against the specification. If you want more detailed information about your document you can use one of many xml validation services. Use your favorite search engine to search for "xml validation".

与往事干杯 2024-08-27 12:43:35

“格式良好的 XML”表示文档符合 W3C 标准。该错误消息意味着您的文档由于某种原因不符合这些标准。例如,那些 标签是非法的,因为它们包含空格。

阅读这样的概述 Developer.com

"Well-formed XML" means the document conforms to the W3C standards. The error message means your document does not meet those standards for some reason. For instance, those <EXTRA TYPE> tags are illegal because they contain spaces.

Read an overview like this one at Developer.com.

乖乖哒 2024-08-27 12:43:35

检查您的文档第 474 行第 15 列是否有任何错误。在该点或该点附近可能有线索。

另外,您是否拼写错误CONFIGURATION?你少了一个“U”。

Check to see if your document has any errors on line 474, column 15. There is probably a clue at or near that point.

Also, did you misspell CONFIGURATION? You are missing a 'U'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文