getPendingTests(); $locations = Location::load(array_column($tests, "location_id")); $dts = date("d/m/Y H:i:s"); $dts_slug = date("Ymd-His"); header("Content-Type: text/xml; charset=utf-8"); header("Content-Disposition: attachment; filename=tests-$dts_slug.kml"); $xml = simplexml_load_file(ROOT_DIR . "/files/empty.kml"); $folder_node = $xml->addChild("Folder"); $folder_node->addChild("name", "Tests"); $folder_node->addChild("open", 1); $folder_node->addChild("description", "Test locations as of $dts"); foreach($locations as $location) { $placemark_node = $folder_node->addChild("Placemark"); $placemark_node->addChild("name", htmlspecialchars($location->name)); $placemark_node->addChild("description", htmlspecialchars($location->getDisplayAddress())); $point_node = $placemark_node->addChild("Point"); $point_node->addChild("coordinates", $location->longitude . "," . $location->latitude); } echo $xml->asXML(); ?>