1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| <?php
$xml = <<< EOX
<?xml version="1.0" encoding="ISO-8859-1"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name><![CDATA[n°1_la_boucle_du_fourneau]]></name>
<open>1</open>
<Snippet maxLines="2"></Snippet>
<description><![CDATA[Exported from n°1_la_boucle_du_fourneau on 02/02/2009]]></description>
<Style id="FEATURES">
<LineStyle>
<color>FFAB007D</color>
<width>1</width>
</LineStyle>
</Style>
<Folder>
<name>Features</name>
<open>0</open>
<Placemark>
<name><![CDATA[1]]></name>
<Snippet maxLines="2"></Snippet>
<styleUrl>#FEATURES</styleUrl>
<LineString>
<extrude>0</extrude>
<tessellate>1</tessellate>
<altitudeMode>clampedToGround</altitudeMode>
<coordinates>
5.36887184445126,47.5261061144012,0
5.36989287672891,47.5263218856547,0
5.37024150309523,47.526158471606,0
5.37053254500734,47.525555713876,0
5.37143741262168,47.5260169766864,0
5.37244855829371,47.5266297484781,0
5.37349347513325,47.5272636702324,0
5.3748908084487,47.5278001831873,0
5.3763781059564,47.5282020676118,0
5.37802160164928,47.5284896258003,0
5.37861779306645,47.5286723752789,0
5.37986446676971,47.5285074207777,0
5.3808730007802,47.5285030002272,0
5.3828213038264,47.5284298109881,0
5.38512701995899,47.5283471965244,0
5.38730149742171,47.5282459449902,0
5.38950593411575,47.5280997787723,0
5.39036268242366,47.5271514368178,0
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name><![CDATA[1]]></name>
<Snippet maxLines="2"></Snippet>
<styleUrl>#FEATURES</styleUrl>
<LineString>
<extrude>0</extrude>
<tessellate>1</tessellate>
<altitudeMode>clampedToGround</altitudeMode>
<coordinates>
5.39047875846544,47.526905911868,0
5.39005224252032,47.5262779034591,0
5.38923205941303,47.5255941265054,0
5.38863207999342,47.5253454030464,0
5.38817342473106,47.5252913424055,0
5.38788227039394,47.525321044394,0
5.3875624097337,47.5254176285788,0
5.3846465027898,47.524502371468,0
5.38403521630821,47.524055538767,0
5.38377880696548,47.5235552953847,0
5.38356371086502,47.5232082644023,0
5.38206491451401,47.5220352847342,0
5.38080744617251,47.5210984215496,0
5.37962254642591,47.5202918970985,0
5.37924882688048,47.520015148162,0
5.3786129100795,47.5202742972107,0
5.37789294328226,47.519631901316,0
5.377239225003,47.5190098069996,0
5.37691415935887,47.5184452219869,0
5.37694896419389,47.5179152878325,0
5.37755594409787,47.5171499263742,0
</coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>
EOX;
$doc = domxml_open_mem($xml, DOMXML_LOAD_DONT_KEEP_BLANKS);
foreach ($doc->get_elements_by_tagname('Placemark') as $placemark) {
$names = $placemark->get_elements_by_tagname('name');
echo $names[0]->get_content();
echo '<ul>';
foreach ($placemark->get_elements_by_tagname('coordinates') as $coordinates) {
foreach (preg_split('/[\s\n\r]/', $coordinates->get_content(), -1, PREG_SPLIT_NO_EMPTY) as $c) {
list($x, $y, $z) = explode(',', $c);
echo '<li>X = ' . $x . ' ; Y = ' . $y . ' ; Z = ' . $z . '</li>';
}
}
echo '</ul>';
} |
Partager