
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.
[adrotate banner=”2″]
Finding the Error
[adrotate banner=”1″]
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->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.
Thanks for the help. Just for anyone info the line is now 3945 in the latest version of wordpress.
I know this is super old but I had a similar problem. WordPress has been updated since. To fix, go to Line 4700 in same file referenced above and replace the word “EMPTY” with “NULL”