Only one top level element is allowed in an XML document while using LR/Blog

Error Appear

I’ve been using Lightroom 3 with LR/Blog to export photo to WordPress for a while. After upgraded to WordPress 3, I’ve face this error: An internal error has occurred: only one top level element is allowed in an XML document. When I click export, the post and photos are upload and posted to the WordPress, but it jump out the error window.

Finding the Error

The way I find out the error. In the Lightroom 3,
File -> Plug-in Manger … Select the LR/Blog … enable the debugging
Log debug information to a file (LRBlog_log.txt) on your desktop

Read the Error

Try to export/upload again and it will be same that display the same error. Then check the log file that appear on your Desktop. LRBlog_log.txt
It will appear these inside the log file.

Returned:

<strong>Warning</strong>: strpos() [<a href="function.strpos">function.strpos</a>]: Empty delimiter in <strong>/home/justin/domains/justin.my/public_html/wp-includes/class-wp-xmlrpc-server.php</strong> on line <strong>2470</strong>
<strong>Warning</strong>: strpos() [<a href="function.strpos">function.strpos</a>]: Empty delimiter in <strong>/home/justin/domains/justin.my/public_html/wp-includes/class-wp-xmlrpc-server.php</strong> on line <strong>2470</strong>
<strong>Warning</strong>: Cannot modify header information - headers already sent by (output started at /home/justin/domains/justin.my/public_html/wp-includes/class-wp-xmlrpc-server.php:2470) in<strong>/home/justin/domains/thamai.net/public_html/wp-includes/class-IXR.php</strong> on line <strong>471</strong>
<strong>Warning</strong>: Cannot modify header information - headers already sent by (output started at /home/justin/domains/justin.my/public_html/wp-includes/class-wp-xmlrpc-server.php:2470) in<strong>/home/justin/domains/thamai.net/public_html/wp-includes/class-IXR.php</strong> on line <strong>472</strong>

 

I found that this is the WordPress bug make the LR/Blog error appear, so I’ve modify the code to solve it.

Solution to solve

Using FTP or vi edit the file.

Find the line 2470 in wp-includes/class-wp-xmlrpc-server.php

Add this

if($file->guid && !($file->guid == NULL))

the line above.

if ( strpos( $post_content, $file-&gt;guid ) !== false )

 

Here is the example to solve:

Modify from:

if ( is_array( $attachments ) ) {
foreach ( $attachments as $file ) {
if ( strpos( $post_content, $file->guid ) !== false )
 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
 }
 }

Modify to:

if ( is_array( $attachments ) ) {
 foreach ( $attachments as $file ) {
 if($file->guid && !($file->guid == NULL))
 if ( strpos( $post_content, $file->guid ) !== false )
 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
 }
 }

After modify, save and try to export from Lightroom 3 with LR/Blog again.


Tags: , , , , , , , , , , , , ,

Translate

Buy me a Caffè Latte

Thank you for the Caffè Latte

2013/02/15 saw art
2013/01/25 Parul Patel
2012/11/20 Barbara Nicholas $10
2012/10/08 Amy Stockman $5
2012/07/15 siewho chang $ 50
2012/06/08 Susan Hampton $10
2012/05/11 Chris Grima $10