dom = new DOMDocument('1.0', 'UTF-8'); $this->dom->formatOutput = true; $kml = $this->dom->createElement('kml'); $kml->setAttribute('xmlns', $xmlns); $this->dom->appendChild($kml); $this->document = $this->dom->createElement('Document'); $kml->appendChild($this->document); } function addMarker($id, $lat, $lng, $title, $description, $icon = 'deficon.png') { $marker = $this->dom->createElement('Placemark'); $marker->setAttribute('id', $id); $name = $this->dom->createElement('name' , $title); $marker->appendChild($name); $desc = $this->dom->createElement('description' , $description); $marker->appendChild($desc); $point = $this->dom->createElement('Point'); $coordinates = $this->dom->createElement('coordinates', $lng . ',' . $lat); $point->appendChild($coordinates); $marker->appendChild($point); $this->document->appendChild($marker); } function getXml() { return $this->dom->saveXML(); } } ?>