
codigo para crear xml
Publicado por juan (14 intervenciones) el 09/06/2014 20:46:24
buenas, estoy trancado porque no se porque funciona este codigo, agradezco ayuda.
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
57
58
59
<?php
// Define the database info
// -- Modify for your case --
include ("conecta.php");
global $db_selected;
global $db;
$db = "datosgpx";
// Important so that the filetype is correct
header("Content-type: application/xml");
// Print the head of the document
printf("'<?'xml version='1.0' encoding='UTF-8''?>'
<kml xmlns=\"http://earth.google.com/kml/2.0\">
<Document>");
/* You can include a default map view using the following lines
// -- Delete this block if you don't need it --
printf("<LookAt>
<latitude>42.390185</latitude>
<longitude>-72.528412</longitude>
<range>1200</range>
<tilt>0</tilt>
<heading>0</heading>
</LookAt>";*/
$query = "SELECT * FROM datosgpx";
//$fecha = mysql_real_escape_string($fecha,$db);
mysql_select_db ("datosgpx");
$result = mysql_query($query);
// echo $result;
// Now iterate over all placemarks (rows)
while ($row = mysqli_fetch_object($result)) {
// This writes out a placemark with some data
// -- Modify for your case --
printf('
<Placemark id="%d">
<name>%s says:</name>
<description>%s</description>
<Point>
<coordinates>%f,%f</coordinates>
</Point>
</Placemark>',
htmlspecialchars($row->fecha),
htmlspecialchars($row->lat),
htmlspecialchars($row->lon),
htmlspecialchars($row->ele),
};
// Close the database connection
mysqli_close($db);
// And finish the document
printf("
</Document>
</kml>");
?>
Valora esta pregunta


0