-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxml.php
More file actions
56 lines (49 loc) · 1.36 KB
/
xml.php
File metadata and controls
56 lines (49 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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
$dbhost = "localhost:3306";
$dbuser = "homenowproject_sxu46";
$dbpass = "Jerry1997!";
$dbname = "homenowproject_lol";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn) {
die('Not connected : ' . mysqli_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($dbname, $conn);
if (!$db_selected) {
die ('Can\'t use db : ' . mysqli_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM addr_2 WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysqli_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<addr>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// Add to XML document node
echo '<addr ';
echo 'name="' . parseToXML($row['COL 2']) . '" ';
echo 'address="' . parseToXML($row['COL 1']) . '" ';
echo 'lat="' . $row['COL 6'] . '" ';
echo 'lng="' . $row['COL 7'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</addr>';
?>