SimpleXML Text Response No Longer Displaying

PHP 5.2.6

From one day to the next, my XML response which parses and writes CDATA to a text file, no longer works. The text file is now empty for some reason. The raw data is there, but the text file is empty.

Here’s the code:

function httpsPost($url, $xml){
// Initialization
$ch=curl_init();
// Set parameters
curl_setopt($ch, CURLOPT_HTTPHEADER, Array(“Content-Type: text/xml”));
curl_setopt($ch, CURLOPT_URL, $url);
// Return a variable instead of posting it directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Active the POST method
curl_setopt($ch, CURLOPT_POST, 1) ;
// Request
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// execute the connexion
$result = curl_exec($ch);
// …close cURL handle ($ch) below
curl_close($ch);
return $result;
}

$url = ‘https://www.somexmlserver.com’;
$sauce = “file.xml”;
$file = file_get_contents ("$sauce");
$xml = utf8_encode($file);
$Response = httpsPost($url, $xml);
$TheData = preg_match_all("/<![CDATA[(.*?)]]>/s", $Response, $url);
$testing = $url[1][0];
$filename = “output.txt”;
$ifp = fopen($filename, “wb” );
fwrite($ifp, $testing);
fclose( $ifp );

I created a loop around the $TheData variable and it just continued to loop without displaying the text.

I was able to echo the $Response data just fine. So the data is there. But it just won’t print out the CDATA that I want, to text.

Also, I can’t get any output from $testing either like I could $Response.

Please help…

Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service