Using wp_remote_get to work with XML in WordPress
Your code so far does retrieve the XML as string:
$url = "http://api.petfinder.com/shelter.getPets?key=1234&count=20&id=abcd&status=A&output=full";$response = wp_remote_get($url);$body = wp_remote_retrieve_body($response);
To load a string (instead of a URL) into a SimpleXMLElement
as you did before with simplexml_load_file
(you didn't show the concrete code so I assume you did it this way based on your description) you now need to load the string with simplexml_load_string
instead:
$xml = simplexml_load_string($body);$code = $xml->header->status->code;
I slightly changed your variable names (especially with the wp_remote_*
functions) to make it more clear for what those variables carry.