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!


  • 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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