0

I added one custom HelloWorld module in a fresh Magento 2 installation and I got the following error:

Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 8 in /var/www/magento2/vendor/magento/framework/Config/Dom.php on line 365

What can be the exact cause for this issue?

I get this error even when I install the sample module from Magento repo. I have not done any edits to the sample module.

It was my custom module causing the problem. Sample module from magento github works fine.

4 Answers 4

2

Sounds like one of your XML files in your module has bad syntax. Make sure every opening tag has a closing tag, and that there is only one root level XML tag per XML file.

2
  • I get this error even when I install the sample module from Magento repo. I have not done any edits to the sample module. github.com/magento/magento2-samples/tree/master/… Jan 14, 2016 at 4:18
  • When do you get the error? Somewhere along the line you may have accidentally changed an XML file; maybe you accidentally deleted a > or similar. Can you look at all recently modified XML files?
    – andyjv
    Jan 15, 2016 at 19:10
0

If you don't know where is empty file and you are using linux. Use this command to get list of empty files.

open terminal and type find /path/to/dest -type d -empty

0

My module was named Chapagain_HelloWorld. The problematic XML file was app/code/Chapagain/HelloWorld/etc/frontend/routes.xml

I don't know what exactly caused the problem. I just replaced the code present there with a similar code from another module and changed the module name, route id, and front name, and then the module worked without any error. But, I could not see any difference between the replaced code and the problematic code.

Here the code of my routes.xml file:

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="helloworld" frontName="helloworld">
            <module name="Chapagain_HelloWorld" />
        </route>
    </router>
</config>
1
  • I faced this issue with empty routes.xml file
    – Mukesh
    Dec 30, 2016 at 7:12
0

For version 2.0 remove the XML version tag at starting of your XML files.

I don't know why but after removing it my code starts working, while the above works for version>2.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.