When trying to import via credentials, I get this error:

Could not load WXR file - problems reported: Opening and ending tag mismatch: encoded line 103119 and script at line 103139 Sequence ']]>' not allowed in content at line 103139 internal error at line 103139 Extra content at the end of the document at line 103139

Tried importing with a WXR file downloaded on my computer, I get no error, no "success" message and nothing imported.

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Looks like you've got a big one there... The error is reported by the XML parser, I suspect that the file may not have been completely downloaded. Can you try opening each file (look in your Drupal installation under files/wordpress) in Firefox, which will do nice formatting if the file is valid XML. If that doesn't work, open each file in a text editor and see what the end of the file looks like, ideally it should end with

  </channel>
</rss>

If the file is complete, see if you can find lines 103119-103139 and see if anything is garbled around there.

moonfiremusic’s picture

Edited those lines and the file displays properly in Firefox. But after importing... "No content available."

mikeryan’s picture

Are you saying those lines were absent, and you simply added them? That won't work - their absence indicates the full file did not get downloaded, and there's going to be more missing than just those lines.

Was the WXR file you downloaded yourself complete (i.e., down to the </rss>) line?

I'm pretty sure this is a matter of the size of the file - can you increase your PHP max_execution_time? In the .htaccess file in the root of your Drupal directory, in the section under <IfModule mod_php5.c>, add the line

  php_value max_execution_time 300

If opening the file you downloaded with an extended max_execution_time works, that indicates we probably need to just spawn off the import rather than trying to start it in the browser...

Thanks.

moonfiremusic’s picture

I've downloaded the file again using another browser, and when I try to open it I get the error:

XML Parsing Error: mismatched tag. Expected: .
Location: file:///C:/Users/Bogdan/Downloads/wordpress.2011-02-09.xml
Line Number 103312, Column 9:
// ]]>

]]>
--------^

The file seems complete, it ends in
It seems to be something wrong with the code. Since the file is complete, I think Wordpress gets the code wrong when exporting, hence the error.
Also did the .htaccess thing, no luck.

mikeryan’s picture

Title: Could not load WXR file - problems reported » Could not load WXR file - mismatched tag
mikeryan’s picture

Oy. The problem is a post with some Javascript that includes CDATA - when rendered within a CDATA in the XML dump, the closing ]] of the Javascript's CDATA is taken as the end of the outer CDATA:

		<content:encoded><![CDATA[Test and stuff here...
<script type="text/javascript">// <![CDATA[
Javascript code here...
// ]]></script>]]></content:encoded>

What WordPress should be doing but isn't is splitting it into consecutive CDATAs, something like this:

		<content:encoded><![CDATA[Text and stuff here...
<script type="text/javascript">// ]]><![CDATA[
Javascript code here...
// ]]><![CDATA[></script>]]></content:encoded>

For us to handle this will require some nasty regex-fu...

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Active
mikeryan’s picture

Title: Could not load WXR file - mismatched tag » Could not load WXR file - mismatched tag due to embedded CDATA
Pyro411’s picture

Mikeryan, got a quick one for you, I saw your project and it gave me hope :) I'm trying to migrate from e107 to Drupal and have to jog through wordpress. I have tried and got this same error with the latest release from June 5th and was wondering is there any changes to the export module I should try in wordpress or, if it helps would you like me to upload my xml file from the export? Fair warning it is about 50 megs in size uncompressed in it's current state.

Thank you for all your work on this.

bcooper’s picture

Maybe this will help. I only needed to pull blog entries over, not pages. I did the following to get it to work:

I only had one record (item) causing issues.

1. I had made the mistake of exporting both pages and blog entries in my WP export so I re-exported and pulled only the blog entries (about 500).
2. I found the "item" causing my problem and removed the complete "item" from my xml file.
3. I set my import settings to import categories and tags from WP as tags in Drupal.
4. I set my import settings to import pages and blogs from WP as blog posts (node type) in Drupal.
5. Format as PHP

This was all with the default path and blog content type settings set to default settings in Drupal.

Next I am going to blow my data out and experiment with path auto and customize the blog content type settings to my liking and see if I can get a more custom result but I was able to get it to work like this. I'll post a follow up once I've worked through with the other settings.

Hope this is helpful to someone!

BC | twitter.com/bill_cooper
http://cooperdm.com

mikeryan’s picture

@knitfreedom - the post titled "Blog Post Template" has some embedded Javascript and a CDATA section which WordPress does not properly handle on export. Also, several others - the common thread seems to be JavaScript for a "Tweet this" button at the end of many articles - you'll need to remove these and re-export to be able to do the Drupal import.

mikeryan’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
knitfreedom’s picture

Hi, thanks for your reply. I feel really frustrated that I can't fix this and move on to working on my site.

Since all of those CDATA and JavaScript "Tweet this" buttons were entered manually on each page (yeah I'll fix that in Drupal - don't want to go through this again), I can't go through and actually take them out of my blog. I have like 130 pages with that code on there.

I tried to manually erase those sections from the XML file using the Find and Replace in TextEdit, but I got another error when trying to import the new file:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?render=overlay&id=21&op=do StatusText: Service unavailable (with message) ResponseText: MigrateException: XMLReader::read() [xmlreader.read]: An Error Occured while reading File /Users/Liat/Desktop/knitfreedom drupal site/sites/all/modules/migrate/plugins/sources/xml.inc, line 732 in MigrationBase->errorHandler() (line 541 of /Users/Liat/Desktop/knitfreedom drupal site/sites/all/modules/migrate/includes/base.inc).

Seems to be the same error as before. Is there any way we can modify the actual XML file to make it import properly, since I can't take the code off the WP site itself? Would you be willing to help me do it, since you know what you're doing and I really don't? I just don't know what it is (besides the obvious Tweet this and Open Like code at the end of my posts) that I should remove, or if manually deleting this stuff will even work.

You have a copy of the XML file - is there any way you could do a find and replace on the bad stuff and check it? Or explain to me what to do?

Thank you so much.

Liat

mikeryan’s picture

The posts causing the problem in your file actually have two Javascript pieces to be removed:

<script type="text/javascript" src="http://openlike.org/v1/openlike.js"></script><script type="text/javascript">// < ![CDATA[
 OPENLIKE.Widget()
// ]]></script>

and

<script type="text/javascript">// < ![CDATA[
 !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
// ]]></script>

The last bit is tricky and you have to be careful - the end of the content looks like

// ]]></script>]]></content:encoded>

You need to be sure to keep that second ]], which is the real terminator for the body content.

It might be that you could get away with simply removing the "// ]]" pattern - it'll break the Javascript of course, but it should leave the XML parsable.

kbell’s picture

I just wanted to pop in and thank you, mikeryan, for helping knitfreedom with her import issues - seriously. ++ on you!
Cheers,
Kelly

knitfreedom’s picture

It worked!!! Thank you, thank you, thank you, thank you!!!

mikeryan’s picture

That's good to know. I've procrastinated on trying to solve this - doing it "right" (properly splitting up CDATA sections etc.) would be a pretty big task, a lot of time to invest for what I had hoped would be a rare situation. Now, I'm wondering if simply removing the "// ]]" will be good enough for most cases...

mikeryan’s picture

Status: Active » Fixed

Went ahead and did it - it will break the Javascript, but I think in most cases the Javascript will be Wordpress-specific stuff that wouldn't work in Drupal anyway...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.