JRMorris77
3/15/2018 - 10:14 AM

Remove invalid line breaks and returns from invalid source XML feed

Remove invalid line breaks and returns from invalid source XML feed

<?php
/*
Script Name: getcleanfeed
Plugin URI: https://premium.wpmudev.org/
Description: Removes invalid line breaks and returns from source feed
Author: James Morris @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sourcesite.com/feed/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$string = str_replace(array("\r", "\n", "\r\n"), ' ', $output);
echo file_put_contents("outputfeed.xml", $string);