WWW_9hub_Net Posted September 26, 2010 Share Posted September 26, 2010 Hello, I'm trying to get webservice response in xml format. I'm getting the response but it's not in xml. It's just text. Can someone please look at the code ? <?php $targeturl="https://api.com"; $DevKey= "xxxxx"; // return xml feed $ch = curl_init($targeturl); curl_setopt($ch, CURLOPT_POST, FAlSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$DevKey)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($ch); $xml = new SimpleXMLElement($response); curl_close($ch); echo $response; // will print in browser all country codes in an xml format /* ADD YOUR OWN CODE HERE TO DO WHAT YOU WANT WITH THE RESPONSE. MAYBE SAVE RESULTS TO A FILE OR THE PARSE THE RESULTS INTO A DATABASE? */ ?> Link to comment https://forums.phpfreaks.com/topic/214415-webservice-response-in-xml/ Share on other sites More sharing options...
BlueSkyIS Posted September 26, 2010 Share Posted September 26, 2010 are you echoing response in a browser window or via command-line? you might not see the xml mark-up if you're executing the code via browser. Link to comment https://forums.phpfreaks.com/topic/214415-webservice-response-in-xml/#findComment-1115868 Share on other sites More sharing options...
WWW_9hub_Net Posted September 26, 2010 Author Share Posted September 26, 2010 Yes I saved the code in php file and tried in browser. Is there anyway I can see the response in xml in browser ? Link to comment https://forums.phpfreaks.com/topic/214415-webservice-response-in-xml/#findComment-1115876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.