I've received that message below when I try to reset my admin password using the Admin panel, I've my custom module installed.

I see this same message on a white screen when I try to access using the tab created in System > Configuration.


Invalid XML in file /var/www/html/rmiorder/app/code/Vendor/Hosebuilder/etc/email_templates.xml: Element 'config': Character content other than whitespace is not allowed because the content type is 'element-only'. Line: 2

Character content other than whitespace is not allowed because the content type is element-only

File XML:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="vendor_hosebuilder_section_general_show_email_template" label="Hose email template for requesting quote" file="hose_request_email_template.html" type="html" module="Vendor_Hosebuilder" area="frontend"/>

How can I solve that issue?

5 Answers 5


This problem you got because the XML code, you copy directly on internet/webpage, there is some hidden character before start each line. This isn't space/ newline character. So, when push to Magento, Magento doesn't know this character, and it shows errors as your message. Solutions: clear all space between tag and order again.

  • Perfect answer solved my issue as well Jul 24, 2018 at 12:01
  • Yes, removing all tags solves the problem. Oct 2, 2020 at 5:16
  • I copied some xml code from some site, and this issue rose.. it was this answer that saved my time. I couldn't see the characters but deleting all spaces/invisible characters before actual code in every line solved my problem. Thanks, Upvoted!
    – MSQ
    May 5, 2021 at 11:17

Check the all and tags in the top of your module files, like theses:


<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">


<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">


<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">


<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="1column">

enter image description here

That was the issue in my case. Their was no way to find in large set of files. debugging steps: open file:

  1. vendor/magento/framework/View/Model/Layout/Update/Validator.php in function public function isValid dump/echo $value in catch and get complete combined layout file in which you are facing issue.
  2. use some editor to found special character.


other way can be open all files in your custom modules related to handler on whcih you are facing issue, like I was facing issue on catalog_product_view page you can see issue in all catalog_product_view.xml files


When the error is caused by a layout file, this article explains how to find the exact file causing the error



In my case the reason was "preference" had no content, i changed from this

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <preference for="Magento\Wishlist\Controller\Index\Add"

to this

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <preference for="Magento\Wishlist\Controller\Index\Add" type="Example\Wishlist\Controller\Index\Add"/>

Your Answer

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

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