• Resolved BAC

    (@bac-1)


    Hi,

    I am not able to successfully parse the Broadbean XML file. The Response is returning “Sorry username and/or password are not valid.” Which is the same response error message I get when visiting the mydomain.com/?wpbb=broadbean (which I also notice is also returning a “500 Internal Server Error” when visiting mydomain.com/?wpbb=broadbean).

    The following error messages appear in the CPanel Error logs:

    [error] PHP Warning: simplexml_load_string(): ^ in /wp-content/plugins/wpbroadbean/wpbb-inbox.php on line 20

    [error] PHP Warning: simplexml_load_string(): xml=<?xml version="1.0" encoding="UTF-8"?> in /wp-content/plugins/wpbroadbean/wpbb-inbox.php on line 20

    [error] PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, ‘<‘ not found in /wp-content/plugins/wpbroadbean/wpbb-inbox.php on line 20

    Line 20 refers to

    19 /* parse the retrieved xml file */
    20 $wpbb_params = json_decode( json_encode( simplexml_load_string( $wpbb_xml_content ) ), 1 );

    Sounds like an encoding or malformed XML, but its pretty difficult to debug.

    Any help would be much appreciated!

    Ben

    https://wordpress.org/plugins/wpbroadbean/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter BAC

    (@bac-1)

    Update:
    I managed to solve this issue. We are using a feed designed for a different plugin and the XML is received URLENCODED with a pesky XML= preceding the XML content, which simplexml_load_string() choked on.

    The simple fix was to urldecode the XML string, then itrim out "xml=".

    Working (simplified) code:

    $wpbb_xml_content = trim(file_get_contents( 'php://input' ));
    
    $wpbb_xml_content = urldecode($wpbb_xml_content);
    
    $wpbb_xml_content = ltrim($wpbb_xml_content, "xml=");

    I also added LIBXML_NOCDATA to the simplexml_load_string() param.

    $wpbb_params = json_decode( json_encode( simplexml_load_string( $wpbb_xml_content,'SimpleXMLElement', LIBXML_NOCDATA ) ), 1 );

    Cheers,
    Ben

    Plugin Author Mark Wilkinson

    (@wpmarkuk)

    Hi Ben, glad you found a solution. I did test the plugin by sending a feed and did not get the same results, however I thin you have covered this in your comments above.

    One thing I would say is not to make changes to the plugin code itself. Obviously if an update to another feature arrives before any changes to what you have outlined above, updating your plugin would loose those changes.

    The plugin does provide a way of using your own inbox.php file to parse the feed. You can include this in your theme in a folder named wpbb. This will then be used instead of the one in the plugin and will protect you from updates.

    Take a look here for how this is done in the plugin:

    https://github.com/wpmark/wpbroadbean/blob/master/wpbroadbean.php#L60-L71

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘XML Feed Parsing Errors’ is closed to new replies.