Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("config.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;
- }
- // Opens a connection to a MySQL server
- $connection=mysqli_connect($databaseHost, $databaseUsername, $databasePassword);
- if (!$connection) {
- die('Not connected : ' . mysqli_error())
- }
- // Set the active MySQL database
- $db_selected = mysqli_select_db($connection, $databaseName);
- if (!$db_selected) {
- die ('Can't use db : ' . mysqli_error());
- }
- // Select all the rows in the markers table
- $query = "SELECT * FROM markers WHERE 1";
- $result = mysqli_query($connection, $query);
- if (!$result)
- die('Invalid query: ' . mysqli_error($connection));
- }
- header("Content-type: text/xml");
- // Start XML file, echo parent node
- echo "<?xml version='1.0' encoding='UTF-8'?>";
- echo '<markers>';
- $ind=0;
- // Iterate through the rows, printing XML nodes for each
- while ($row = @mysqli_fetch_assoc($result))
- // Add to XML document node
- echo '<marker ';
- echo 'id="' . $row['id'] . '" ';
- echo 'name="' . parseToXML($row['name']) . '" ';
- echo 'address="' . parseToXML($row['address']) . '" ';
- echo 'contact_number="' . parseToXML($row['contact_number']) . '" ';
- echo 'contact_number1="' . parseToXML($row['contact_number1']) . '" ';
- echo 'contact_number2="' . parseToXML($row['contact_number2']) . '" ';
- echo 'lat="' . $row['lat'] . '" ';
- echo 'lng="' . $row['lng'] . '" ';
- echo 'image="' . $row['image'] . '" ';
- echo '/>';
- $ind = $ind + 1;
- }
- // End XML file
- echo '</markers>';
- ?>
Add Comment
Please, Sign In to add comment