错误:XML 文档结构必须在同一实体内开始和结束
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37116985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: XML document structures must start and end within the same entity
提问by user6309006
I am new to XML and getting the below error:
我是 XML 新手并收到以下错误:
Error: XML document structures must start and end within the same entity
错误:XML 文档结构必须在同一实体内开始和结束
Input XML:
输入 XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<test>
<access1>113AL</access1>
<access2>119AL</access2>
</test>
<test>
<access2>115AL<s/access2>
<access3>116AL</access3>
</test>
<test>
<access4>118AL</access4>
<access5>119AL</access5>
</test>
<copies>
<test2>
<access>113AL</access>
<Copy>Y</Copy>
</test2>
<test2>
<access>113AX</access>
<Copy>N</Copy>
</test2>
</copies>
</root>
采纳答案by kjhughes
Your XML is not well-formed. In general, this error indicates that something is wrong with the range of the start and end tags.
您的 XML 格式不正确。 通常,此错误表示开始和结束标记的范围有问题。
In particular in your case, you have a stray sin one of the closing access2tags:
特别是在您的情况下,您s在一个结束access2标签中有一个流浪:
<access2>115AL<s/access2>
Here is your XML with the problem resolved; it is now well-formed (and indented to improve readability):
这是问题已解决的 XML;它现在格式良好(并缩进以提高可读性):
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<test>
<access1>113AL</access1>
<access2>119AL</access2>
</test>
<test>
<access2>115AL</access2>
<access3>116AL</access3>
</test>
<test>
<access4>118AL</access4>
<access5>119AL</access5>
</test>
<copies>
<test2>
<access>113AL</access>
<Copy>Y</Copy>
</test2>
<test2>
<access>113AX</access>
<Copy>N</Copy>
</test2>
</copies>
</root>

