我的 xml 文件中出现此错误:XML Parsing error: Extra content at the end of the document
我正在使用 Notepad++,它在标题标签中以红色显示第二个词 <ABC BLAH>hello</ABC BLAH>
- 它以红色显示 BLAH。因此,我假设问题出在 header 标签的空白处,并在该行抛出验证错误。我该如何解决这个问题?
这是 xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<Order>1</Order>
<Requirements>ABC</Requirements>
<Testing Procedures>blah blah </Testing Procedures>
<Assessment Observations / Comments>blah blah</Assessment Observations / Comments> <-- throws Parsing error at this line.
</row>
</rows>
最佳答案
<Testing Procedures="">blah blah </Testing Procedures>
元素名称中不能有空格。
<Assessment Observations="" / Comments>blah blah</Assessment Observations / Comments>
这也有多个错误。也许你的意思是这个? :
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<Order>1</Order>
<Requirements>ABC</Requirements>
<TestingProcedures foo=" ">blah blah </TestingProcedures>
<Assessment Observations="/ Comments>blah blah"/>
<Assessment Observations=" / Comments"/>
</row>
</rows>
您有多个错误。无法真正说明您要做什么。
确定 .xml 101:
XML 不允许在元素名称中使用空格。
如果您不关闭元素名称,您可以像这样指定属性。
<foo bar="I am an attribute" lol="Me too"> Here you can specify text, or other elements </foo>
此外,如果一个元素不包含另一个元素或文本,您可以使用速记符号
<foo attribute="bar"/>
我建议您阅读一些基础知识 tutorial为此。
关于XML 解析错误 : Extra content at the end of the document,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8189117/