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.
Message:
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"/>
</config>
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 wellPandurang Babar– Pandurang Babar2018年07月24日 12:01:32 +00:00Commented Jul 24, 2018 at 12:01
-
Yes, removing all tags solves the problem.Jaykumar Pipaliya– Jaykumar Pipaliya2020年10月02日 05:16:40 +00:00Commented 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– MSQ2021年05月05日 11:17:42 +00:00Commented May 5, 2021 at 11:17
Check the all and tags in the top of your module files, like theses:
etc/frontend/routes.xml
<?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">
etc/email_templates.xml
<?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">
etc/module.xml
<?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">
view/frontend/layout/vendor_hosebuilder_index_index.xml
<?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">
That was the issue in my case. Their was no way to find in large set of files. debugging steps: open file:
- 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.
- use some editor to found special character.
OR
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"
type="Example\Wishlist\Controller\Index\Add">
</preference>
</config>
to 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" type="Example\Wishlist\Controller\Index\Add"/>
</config>