.csv to rss-feed in php

Links for php scripts

Moderators: macek, egami, gesf

christoph
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Aug 13, 2012 1:40 am

.csv to rss-feed in php

Postby christoph » Mon Aug 13, 2012 1:45 am

-
Last edited by christoph on Mon Aug 13, 2012 1:06 pm, edited 1 time in total.

christoph
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Aug 13, 2012 1:40 am

Re: .csv to rss-feed in php

Postby christoph » Mon Aug 13, 2012 1:05 pm

This code works now.

Code: Select all

<?php header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
    <title>PEGELMV</title>
    <link>http://www.pegelmv.de</link>
    <description>Katastrophenschutz- Vorwarnsystem PEGELMV</description>
    <language>de-de</language>
    <pubDate><?php echo date("D, d M Y H:i:s",time()+120*60); ?> +0200</pubDate>
    <lastBuildDate><?php echo date("D, d M Y H:i:s",time()+120*60); ?> +0200</lastBuildDate>
    <docs>http://www.pegellatte.de/rss019.php</docs>
    <generator>PHP RSS-Feed</generator>
    <managingEditor>info@pegelmv.de (Christoph Kastius)</managingEditor>
    <webMaster>info@pegelmv.de (Christoph Kastius)</webMaster>
    <?php
    ini_set('auto_detect_line_endings', TRUE);
    $handle = fopen("daten/pegel019.csv", "r");

    $data;

       while (($currentData = fgetcsv($handle, 1000, ";")) !== FALSE)
       {
          $data = $currentData;
       }
 ?>
 <atom:link href="http://www.pegellatte.de/rss019.php" rel="self" type="application/rss+xml" />
    <item>
    <title>Pegel 019 - Greifswald</title>
    <link>
    http://www.pegellatte.de/pegel019.php
    </link>
    <pubDate>
    <?php echo date("D, d M Y H:i:s",time()+120*60); ?> +0200</pubDate>
    <description>
    Dieser Pegel hat einen Fuellstand von <?php  echo $data[0]; ?> cm, welcher am <?php  echo $data[1]; ?> um <?php  echo $data[2]; ?> Uhr gemessen wurde.
    </description>
    <guid>http://www.pegellatte.de/pegel019.php</guid>
   </item>
</channel>
</rss>
<?php
fclose($handle);
?>

christoph
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Aug 13, 2012 1:40 am

Re: .csv to rss-feed in php

Postby christoph » Mon Aug 13, 2012 1:08 pm



Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest