2017-07-07 73 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大家

相關問題