1. Read the exported xml file using online xml reader, eg.: http://view.xmlgrid.net/

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

 

2. Also compare the expored xml content by viewing in the text editor, please note there are some information written as attribute and mostly as element

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

3. See the structure of wordpress comment table ‘vtm7487_comments’ , this will be the target of our export actvity, please ensure you do the ‘vtm7487_comments’ table backup Export Comment From DISQUS To WordPress – Part 2 | the atmojo prior to the importing process

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

4. Start to parse the exported xml into variable that ready to be inserted to Database, i’m using PHP to achieve this .

First, load the comment (xml file) and parse it into DOM by using simplexml_load_file(), the result will be stored in $xml variable, i assume using ‘panjiatmojo.xml’ as the xml file source

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

5. Inside the $xml, contains 3 element: category, thread & post. We’ll focus on the thread and post element only. Fetch all comment under post element by using function get_post() and store the result under $comments variable

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

6. Do the loop for $comments variable to parse the xml comment into wordpress-formatted by using below step, there are several functions called to do the parsing (will be explained later), after parsing done the wordpress-formatted comment will be inserted in to the ‘wp’ database.

The trickiest part is to provide the comment_post_id, since DISQUS using totaly different post id to identify the “post location” or the “post title” of the comments. The workaround is to find the nearest match (using levenstein) of “post title” or “post link” with the “post title” from the wp database.

Export Comment From DISQUS To WordPress – Part 2 | the atmojo

7. Importing comment from DISQUS to WordPress is done you can check this by viewing on the ‘vtm7487_comments’ table in ‘wp’ database. Good Luck Export Comment From DISQUS To WordPress – Part 2 | the atmojo

Export Comment From DISQUS To WordPress – Part 2 | the atmojo