芝麻web文件管理V1.00
编辑当前文件:/home/prismawe/www/blog/wp-content/plugins/xml-google-maps/xmlgooglemaps_kmlParser.php
xml_obj = xml_parser_create(); xml_set_object($this->xml_obj,$this); xml_set_character_data_handler($this->xml_obj, 'dataHandler'); xml_set_element_handler($this->xml_obj, "startHandler", "endHandler"); $old = error_reporting(1); $filecontent = xmlgooglemaps_helper::getFileContent($url); if ($filecontent === false) { xml_parser_free($this->xml_obj); error_reporting($old); return false; } else { error_reporting($old); } if (!xml_parse($this->xml_obj, $filecontent)) { xml_parser_free($this->xml_obj); return false; } xml_parser_free($this->xml_obj); return true; } function startHandler($parser, $name, $attribs){ switch ($name) { case "COORDINATES": $this->currentdata=null; $this->currentdataarray=array(); $this->readingdata=1; break; default: //echo $name."
"; break; } } function dataHandler($parser, $data){ if ($this->readingdata) { $this->currentdata = $data; $this->currentdataarray[$this->readingdata] = trim($data); $this->readingdata++; } } function endHandler($parser, $name){ $this->readingdata=0; switch ($name) { case "COORDINATES": for ($i=1; $i<=count($this->currentdataarray);$i++) { preg_match_all('/([0-9\-]+?.[0-9]+?),/', $this->currentdataarray[$i], $found); if ((count($found) == 2)) { for ($j; $j
output["coordinates"][$this->coordinatescount]["lon"] = $found[1][$j+0]; $this->output["coordinates"][$this->coordinatescount]["lat"] = $found[1][$j+1]; $this->coordinatescount++; } } } break; default: break; } } } ?>