Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. function parseToXML($htmlStr)
  3. {
  4. $xmlStr=str_replace('<','<',$htmlStr);
  5. $xmlStr=str_replace('>','>',$xmlStr);
  6. $xmlStr=str_replace('"','"',$xmlStr);
  7. $xmlStr=str_replace("'",'&#39;',$xmlStr);
  8. $xmlStr=str_replace("&",'&',$xmlStr);
  9. return $xmlStr;
  10. }
  11.  // Verbindung zur Datenbank herstellen
  12.  $host = "localhost";
  13.         $port = "5432";
  14.         $user = "postgres";
  15.         $password = "postgres";
  16.         $dbname = "apothekenfinder";
  17.  
  18.     $connection = "password=$password dbname=$dbname user=$user port=$port host=$host";
  19.     $dbconn = pg_connect($connection);
  20.  
  21.     // Select all the rows in the markers table
  22. $query = "SELECT * FROM apothekenfinder_epsg4326";
  23. $result = pg_query($query);
  24.  
  25. header("Content-type: text/xml");
  26.  
  27. // Start XML file, echo parent node
  28. echo '<markers>';
  29.  
  30. // Iterate through the rows, printing XML nodes for each
  31. while ($row = @pg_fetch_assoc($result)){
  32.   // ADD TO XML DOCUMENT NODE
  33.   echo '<marker ';
  34.   echo 'name_apotheke="' . parseToXML($row['name_apotheke']) . '" ';
  35.   echo 'strasse_und_nr="' . parseToXML($row['strasse_und_nr']) . '" ';
  36.   echo 'plz="' . parseToXML ($row['plz']) . '" ';
  37.   echo 'gemeinde="' . parseToXML ($row['gemeinde']) . '" ';
  38.   echo 'lat="' . parseToXML ($row['lat']) . '" ';
  39.   echo 'lng="' . parseToXML ($row['lng']) . '" ';
  40.   echo '/>';
  41. }
  42.  
  43. // End XML file
  44. echo '</markers>';?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement