I wonder why you use cURL as SimpleXML itself can load URLs: $vastdata = new SimpleXMLElement('http://afe.specificclick.net/?l=32259&t=x&rnd=123456',0,true); See http://de.php.net/manual/en/simplexmlelement.construct.php Am 09.02.2012 04:44, schrieb Rob Gould: > Can anyone tell me what I'm doing wrong here? I'm trying to get the VASTAdTagURI field from the XML data at this url: > > http://afe.specificclick.net/?l=32259&t=x&rnd=123456 > > > > > Here's my code. (below). It works maybe 30% of the time, but most of the time it just returns nothing from that field. Yet when I go to the above url in Firefox, I always see the data. This is very strange. > > > > > > // Lets get the ad! > > $curl_handle=curl_init(); > curl_setopt($curl_handle,CURLOPT_URL,'http://afe.specificclick.net/?l=32259&t=x&rnd=123456'); > curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); > curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); > $buffer = curl_exec($curl_handle); > curl_close($curl_handle); > > $vastdata = new SimpleXMLElement($buffer); > > $vasturi = $vastdata->Ad->Wrapper->VASTAdTagURI; > > echo "If the script works, vasturi = " . $vasturi; > > echo "<br><br><br>"; > > print_r($vastdata); > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php