2017-07-07 72 views
0
$kml = new SimpleXMLElement('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"></kml>'); 

$kml->addChild('Document'); 
$kml->Document->addChild('Folder'); 
$kml->Document->addChild('Folder'); 
$kml->Document->addChild('Folder'); 
$kml->Document->Folder->addChild('name','a'); 
$kml->Document->Folder->addChild('name','b'); 
$kml->Document->Folder->addChild('name','c'); 

我想用PHP从XML 做出KML,但只显示在谷歌地球文件夹中。我需要在一个Web文件夹,以显示三个文件夹 像:怎样的addChild两个“文件夹”,一个是点,另一个是多边形

↓口聚(网络文件夹)

↓口a (folder) 
    →point1 
    →point2 
↓口b (folder) 
    →polygon1 
    →polygon2 
↓口c (folder) 
    →polyline1 
    →polyline2 

回答

0
$kml->Document->addChild('Folder'); 
$kml->Document->Folder->addChild('name','a'); 
$kml->Document->addChild('Folder'); 
$kml->Document->Folder[1]->addChild('name','b'); 
$kml->Document->addChild('Folder'); 
$kml->Document->Folder[2]->addChild('name','c'); 

它`工作

THX大家

相关问题