How do I pull XML data from a local PHP script?

Affithlof

New Member
I am currently pulling data from a MySQL Database using PHP, converting it into XML, then displaying it on a page. I do this with the following code:\[code\]$XMLData = "http://stackoverflow.com/questions/12760920/<?xml version=\"1.0\"?>\n";$XMLData .= "<listings>\n";for ($x = 0; $x < $numOfRows; $x++) { //Get a row of data $row = mysqli_fetch_assoc($res); //Create a new entry in XMLData $XMLData .= "\t<listing>\n"; foreach ($row as $key => $value) { $XMLData .= "\t\t<" . $key . ">"; $XMLData .= $value; $XMLData .= "</" . $key . ">\n"; } $XMLData .= "\t</listing>\n";}$XMLData .= "</listings>\n";echo $XMLData;\[/code\]I have another PHP script that I need to pull the XML from the first script. I have tried \[code\]file_get_contents\[/code\] as well as PHP-cURL but I get no data from either. I tried using cURL in a function I found from another post here on SO:\[code\]function download_page($path){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$path); curl_setopt($ch, CURLOPT_FAILONERROR,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $retValue = http://stackoverflow.com/questions/12760920/curl_exec($ch); curl_close($ch); return $retValue;}\[/code\]But nothing gets returned to me. What am I doing wrong?Also, I should mention the way I am sending the request is through $_GET for example:\[code\]$test = download_page("./listings.php?title=aListing");print_r($test);\[/code\]
 
Back
Top