0

I cannot see the front or back end of my website all a get is an error screen with this...

Warning: simplexml_load_string(): Entity: line 2: parser error : Start tag expected, '<' not found in /var/www/vhosts/aspectspools.co.uk/httpdocs/lib/Varien/Simplexml/Config.php on line 510

Trace:

#0 [internal function]: mageCoreErrorHandler(2, 'simplexml_load_...', '/var/www/vhosts...', 510, Array)
#1 /var/www/vhosts/aspectspools.co.uk/httpdocs/lib/Varien/Simplexml/Config.php(510): simplexml_load_string('

I was experimenting with cart2cart and uploaded a some files to make a connection bridge and now when I went to the website with any url front or /admin I get the above message.

What has happened?

Using version 1.3. I deleted the installed files but it did not help.

2
  • @ Rick Buczynski Thanks for the reply ( I can't add a comment because I am a newbie). My user name has changed since I posted too! I tried your solution but it did not work. I just got the same error message as before but with "line 513" instead of "line 510" where I moved the code down the page to fit the new code in.
    – user18956
    Jan 3, 2015 at 22:22
  • Hi @user18956 - I've updated my answer below. Try both methods to see which will work for you. Jan 4, 2015 at 19:17

1 Answer 1

1

This one is always annoying because, short of using xdebug or other tracing up front, you won't know the file where this issue originated (or its path is often clipped in the trace output).

NOTE: Please ensure that you have taken the correct measures to configure your store for optimal debugging. See Fundamentals for debugging a Magento store for more information.

Method A

Try this. Temporarily, modify [SITE_ROOT]/lib/Varien/Simplexml/Config.php:

public function loadFile($filePath)
{
    if (!is_readable($filePath)) {
        //throw new Exception('Can not read xml file '.$filePath);
        return false;
    }

    $fileData = file_get_contents($filePath);
    $fileData = $this->processFileData($fileData);

    // Begin debugging
    try {
        return $this->loadString($fileData, $this->_elementClass);
    } catch (Exception $error) {
        echo $error->getMessage() . '<br/>' . $filePath;
        exit;
    }
    // End debugging
}

Here you're trying to catch any exceptions, and print the file path before cutting off the process. So access your store again, and you should immediately see the source. If for some reason this method doesn't work, see below.

Once you identify the culprit file, open it in your IDE and fix the bad syntax. Then remove your logging from above and try again.

Method B

If you have access to the shell on your server and have the xmllint tool installed on the system, run this awesome one-liner from MageInferno.

find app/code/local/ -type f -name "*.xml" -exec xmllint --noout {} \;

Where you must adjust app/code/local/ to point to the folder(s) you want to scan for XML errors. For example, if the cart2cart extension was installed in the community code pool, then your path must be app/code/community.

1
  • 1
    Great thanks for method B. I tried to make an error in xml file, to see how it works (remove one '<' element. and I got '/config>' tag instead of </config>). Then I executed this script and got following error: app/code/local/Zhartaunik/Updates/etc/config.xml:56: parser error : Premature end of data in tag config line 2 /config> ^. Thanks one again, if I know this feature before - I could save some time on searching for such issues.
    – zhartaunik
    May 10, 2015 at 7:24

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.