Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Haven't worked much with XML so I'm hitting a bit of a wall:

function getapi() 
{
    $api_response = wp_remote_get( "http://example.com/getXML" );
    $data         = wp_remote_retrieve_body( $api_response );
    $output       = new SimpleXMLElement ($data );

    return $output;
}

Get or set the Transient

function transient()
{ 
    $transient = get_transient( 'transient_value' );

    if ( ! $transient ) {
        $transient = getapi();
        set_transient( 'transient_value', $transient, 180 );
    }

    return $transient;
}

I can easily show the data, but calling it up from a stored transient results in this error being shown:

Node no longer exists in C:\xampplite\htdocs\...

Not sure what the extra step is that I need to perform in order to store the data correctly.

Many thanks!

Noel

share|improve this question
    
Add the code that you're using to set/retrieve the transient so we can better help you out. –  EAMann Jul 6 '11 at 20:28
    
Yep, added! I've simplified all the naming, and I've got no problems with all the json api's, it's just that XML data probably needs to be stored differently. Cheers –  Noel Tock Jul 6 '11 at 20:40
add comment

1 Answer

up vote 5 down vote accepted

According to this ticket:

Cannot serialize object wrapping 3rd party library structs. Must serialize the xml (to a string) and store that to session and reload the xml when restoring from session

When you are storing object in transient it gets serialized and not all objects are capable of that correctly.

Store textual XML data in transient instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.