1

After installing wordpress importer from Tools option in wordpress, when I try to activate it, it gives fatal error.

Screenshot

The relevant php code:

class WXR_Parser {
    function parse( $file ) {
        // Attempt to use proper XML parsers first
        if ( extension_loaded( 'simplexml' ) ) {
            $parser = new WXR_Parser_SimpleXML;
            $result = $parser->parse( $file );

            // If SimpleXML succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() )
                return $result;
        } else if ( extension_loaded( 'xml' ) ) {
            $parser = new WXR_Parser_XML;
            $result = $parser->parse( $file );

            // If XMLParser succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() )
                return $result;
        }

        // We have a malformed XML file, so display the error and fallthrough to regex
        if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) {
            echo '<pre>';
            if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
                foreach  ( $result->get_error_data() as $error )
                    echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
            } else if ( 'XML_parse_error' == $result->get_error_code() ) {
                $error = $result->get_error_data();
                echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
            }
            echo '</pre>';
            echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />';
            echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>';
        }

        // use regular expressions if nothing else available or this is bad XML
        $parser = new WXR_Parser_Regex;
        return $parser->parse( $file );
    }
}

3 Answers 3

4

That error suggests that the WXR_Parser class is already "running" or declared. It's possible that a theme or another plugin has incorporated that class and did not check if it existed already before initializing. ie. if ( ! class_exists( 'WXR_Parser' ) ).

To locate the source of the conflict, deactivate each theme and plugin one-by-one. You should be left with just a default theme active (ie. TwentyFifteen).

4
  • I deactivated all the plugins one by one but the error still persist. Is there anything else we can do @jami0821 ?
    – Rahul
    Dec 28, 2016 at 7:36
  • Activate the default theme (TwentyFifteen or TwentySixteen).
    – Jami Gibbs
    Dec 28, 2016 at 20:44
  • after activating the default theme, I was able to activate. Could you add the second method in your answer so that I can mark it as done.
    – Rahul
    Dec 29, 2016 at 5:40
  • @Rahul Glad that helped. I added clarification and appreciate you accepting it. Cheers!
    – Jami Gibbs
    Dec 29, 2016 at 12:06
1

This happened with me too.

I did not go to code section for this.

I changed the activated-theme to Twenty-Sixteen and then I tried to activate the plugin and succeed.

0

i had same error with a theme, then I switched to wordpress default theme, then installed the worpress importer.... its installed and working well. then I changed my favourite theme, which is working well. Thanks.

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.