Curl and htmlentities stripping XML tags

DrDodgers

New Member
So i'm working on a php script which passes information to a server using Curl and the POST method and then takes back information from that server in the form of XML.I then want to take this information and parse it into a readable format for the user. I grab the information using curl and load it into a variable ($result) which i then want to load into simpleXML and store in the variable $routeinfo. However when I perform a var_dump($routeinfo) there doesn't appear to be any data stored. I've confirmed that there is data present in $result by echoing it. I also figured it may have been due to the XML not showing up in the browser when I echoed $result(but it is there if I check the source). Just to check though I used htmlentities but that causes a lot of errors because < is interpreted as it's html equivalent. Anyway I've reached an impass and have logged quite a few hours implementing different suggestions to no avail. My code is below and I would appreciate any help that can be rendered.\[code\]<?php //retrieve form data in a variable$input = $_POST['stopNo'] ;//declare other variables needed$api_key = 'xxxkey' ;$api_id = 12345 ;$url = 'url to send data to' ; $querystring = "appID=". $api_id . "&apiKey=" . $api_key . "&stopNo" . $input ;$data = http://stackoverflow.com/questions/10670818/urlencode($url) ; //curl using$ch = curl_init() ; //set up curlcurl_setopt($ch, CURLOPT_URL,'urlsendingdatato');curl_setopt($ch, CURLOPT_POSTFIELDS, 'appID='.urlencode($api_id).'&apiKey=' .urlencode($api_key) . '&stopNo=' .urlencode($input) );curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, 0 ) ; curl_setopt($ch, CURLOPT_ENCODING, "UTF-8") ;curl_setopt($ch, CURLOPT_BINARYTRANSFER , TRUE) ;//execute and gather info$result = curl_exec($ch) ; //close connectioncurl_close($ch) ;//format data //ent at the moment serves no purpose doesn't render the information correctly$ent = htmlentities($result);$routeinfo = new SimpleXMLElement($result) ;//print dataecho "<br> $result <br>" ; var_dump($routeinfo) ;?> \[/code\]
 
Back
Top