xml

Error: XML document structures must start and end within the same entity


I am new to XML and getting the below error:

Error: XML document structures must start and end within the same entity

Input 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>

Solution

  • Your XML is not well-formed. In general, this error indicates that something is wrong with the range of the start and end tags.

    In particular in your case, you have a stray s in one of the closing access2 tags:

        <access2>115AL<s/access2>
    

    Here is your XML with the problem resolved; it is now well-formed (and indented to improve readability):

    <?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>