如何添加两个'文件夹',一个是点,另一个是多边形

时间:2017-07-07 02:40:54

标签: php xml directory addchild

$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 但只在Google地球中显示文件夹a。我需要在Web文件夹中显示三个文件夹 像:

↓口poly(网络文件夹)

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

1 个答案:

答案 0 :(得分: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 everyone