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? */ ?> Quote Link to comment 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. Quote Link to comment 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 ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.