Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function parseToXML($htmlStr)
- {
- $xmlStr=str_replace('<','<',$htmlStr);
- $xmlStr=str_replace('>','>',$xmlStr);
- $xmlStr=str_replace('"','"',$xmlStr);
- $xmlStr=str_replace("'",''',$xmlStr);
- $xmlStr=str_replace("&",'&',$xmlStr);
- return $xmlStr;
- }
- // Verbindung zur Datenbank herstellen
- $host = "localhost";
- $port = "5432";
- $user = "postgres";
- $password = "postgres";
- $dbname = "apothekenfinder";
- $connection = "password=$password dbname=$dbname user=$user port=$port host=$host";
- $dbconn = pg_connect($connection);
- // Select all the rows in the markers table
- $query = "SELECT * FROM apothekenfinder_epsg4326";
- $result = pg_query($query);
- header("Content-type: text/xml");
- // Start XML file, echo parent node
- echo '<markers>';
- // Iterate through the rows, printing XML nodes for each
- while ($row = @pg_fetch_assoc($result)){
- // ADD TO XML DOCUMENT NODE
- echo '<marker ';
- echo 'name_apotheke="' . parseToXML($row['name_apotheke']) . '" ';
- echo 'strasse_und_nr="' . parseToXML($row['strasse_und_nr']) . '" ';
- echo 'plz="' . parseToXML ($row['plz']) . '" ';
- echo 'gemeinde="' . parseToXML ($row['gemeinde']) . '" ';
- echo 'lat="' . parseToXML ($row['lat']) . '" ';
- echo 'lng="' . parseToXML ($row['lng']) . '" ';
- echo '/>';
- }
- // End XML file
- echo '</markers>';?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement