2

While i create a router in magento 2.2.6 module i face the following error

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /var/www/html/magento/app/code/Bz/Bcs/etc/frontend/routes.xml:
Element 'config', attribute '{http://www.w3.org/2001/XMLSchemainstance}noNamespaceSchemaLocation': The attribute '{http://www.w3.org/2001/XMLSchemainstance}noNamespaceSchemaLocation' is not allowed.
Line: 2

Element 'config': Character content other than whitespace is not allowed because the content type is 'element-only'.
Line: 2

Element 'router': Character content other than whitespace is not allowed because the content type is 'element-only'.
Line: 3

Element 'route': Character content other than whitespace is not allowed because the content type is 'element-only'.
Line: 4

Element 'route': Character content other than whitespace is not allowed because the content type is 'element-only'.
Line: 4

Element 'router': Character content other than whitespace is not allowed because the content type is 'element-only'.
Line: 3

My routes.xml code is

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="blaze" frontName="blazeaccess">
            <module name="Bz_Bcs" />
        </route>
    </router>
</config>
1
  • Have you copied the code from somewhere and pasted into your file? Nov 20, 2018 at 10:20

2 Answers 2

1

Looks like you have added by mistake white space in your routes.xml file

Please check where you added it.

The error says before start each tag like router, route, and module you have white spaces.

0

Try the below code instead of yours:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
    <router id="standard">
        <route id="blaze" frontName="blazeaccess">
            <module name="Bz_Bcs" />
        </route>
    </router>
</config>

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.