Texan78 Posted June 6, 2013 Share Posted June 6, 2013 I have a XML file that I am trying to create a RSS feed from but I am having a hard time adding the headers. It should look like this.... <?xml version="1.0"?> <rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>Mesquite Area Storm Reports</title> <link>http://www.mesquiteweather.net/wxmesqLSR.php</link> <description>Courtesy of Mesquite Weather</description> <language>en-us</language> <copyright>Mesquite Weather</copyright> <ttl>15</ttl> <image> <url>http://www.mesquiteweather.net/images/App_75_x_75.png</url> <width>75</width> <height>75</height> </image> <entrys> <reports> <timestamp>Wed Jun 5th 10:13 pm</timestamp> <name>Unknown</name> <location>Mesquite</location> <report>WIND DAMAGE</report> <description>Enter report description</description> </reports> </entrys> </channel> </rss> But instead it comes out like this. http://www.mesquiteweather.net/xml/mesquite.xml But if you run the script it is RSS but no data. http://www.mesquiteweather.net/xml/process.php Here is the php script.... <?php if (isset($_POST['lsr-submit'])) { header('Location: http://www.mesquiteweather.net/wxmesqLSR.php'); } $str = '<?xml version="1.0" encoding="UTF-8"?><entrys></entrys>'; $xml = false;if(file_exists('mesquite.xml')) $xml = simplexml_load_file('mesquite.xml'); if(!$xml) $xml = simplexml_load_string('<entrys/>'); $rssfeed .= '<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">'; $rssfeed .= '<channel>'; $rssfeed .= '<title>Mesquite Area Storm Reports</title>'; $rssfeed .= '<link>http://www.mesquiteweather.net/wxmesqLSR.php</link>'; $rssfeed .= '<description>Courtesy of Mesquite Weather</description>'; $rssfeed .= '<language>en-us</language>'; $rssfeed .= '<copyright>Mesquite Weather</copyright>'; $rssfeed .= '<image>'; $rssfeed .= '<url>http://www.mesquiteweather.net/images/App_75_x_75.png</url>'; $rssfeed .= '<width>75</width>'; $rssfeed .= '<height>75</height>'; $rssEnd .= '</channel>'; $rssEnd .= '</rss>'; $name = $_POST['name']; $location = $_POST['location']; $report = $_POST['report']; $description = $_POST['desc']; $fname = htmlentities($fname, ENT_COMPAT, 'UTF-8', false); $lname = htmlentities($lname, ENT_COMPAT, 'UTF-8', false); $location = htmlentities($location, ENT_COMPAT, 'UTF-8', false); $report = htmlentities($report, ENT_COMPAT, 'UTF-8', false); $description = htmlentities($description, ENT_COMPAT, 'UTF-8', false); echo $rssfeed; $reports = $xml->addChild('reports'); $reports->addChild('timestamp', date("D M jS g:i a",time())); $reports->addChild('name', $name); $reports->addChild('location', $location); $reports->addChild('report', $report); $reports->addChild('description', $description); echo $rssEnd; $doc = new DOMDocument('1.0'); $doc->formatOutput = true; $doc->preserveWhiteSpace = true; $doc->loadXML($xml->asXML(), LIBXML_NOBLANKS); $doc->save('mesquite.xml'); ?> Is there an easier way to do this? Quote Link to comment Share on other sites More sharing options...
Texan78 Posted June 6, 2013 Author Share Posted June 6, 2013 Never mind.... It's missing the required RSS elements. 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.