I’ve exported a WordPress export file for import into a new WordPress site.
However, I get the error “This does not appear to be a WXR file, missing/invalid WXR version number”
After some searching, it appeared to be a character encoding issue. I tried running the following code:
$content = utf8_encode(file_get_contents('my-import-file.xml')); $invalid_characters = '/(^x9xax20-xD7FFxE000-xFFFD)/'; $content = preg_replace($invalid_characters, '', $content ); echo htmlentities($content);
This produced a string that I can copy and paste into a .xml file that I can then successfully import into my site. However, this string has lots of broken characters, such as “â”. Upon comparing with my original string, it seems like these are single quotes, double quotes, dashes, etc.
Based on the answers suggested in this thread, I tried running the following code:
$content = file_get_contents('my-import-file.xml'); $output = iconv('UTF-8', 'ASCII//TRANSLIT', $content); echo htmlentities( $output );
This gives me a blank screen with only the following error:
Notice: iconv(): Detected an illegal character in input string in /srv/www/my-site/public_html/load-string.php on line 5
My source site that I’m exporting from is fairly old (created around 2012 or so), but my
wp-config.php on my source site has the following set:
/** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');