The xml structure is exactly that xml you sent:
For example:
<Document>
<Placemark>
<name>356HH</name>
<description>
</description>
<Polygon><outerBoundaryIs><LinearRing><coordinates>some cordinates here</coordinates></LinearRing></innerBoundaryIs></Polygon>
<Style><LineStyle><color>ff0000ff</color></LineStyle> <PolyStyle><fill>0</fill></PolyStyle></Style>
</Placemark>
<Placemark>
</document>
А это мой php код:
<?php
$completeurl = "2.xml";
$xml = simplexml_load_file($completeurl);
$placemarks = $xml->Document->Placemark;
$con=mysqli_connect("localhost","root","","j3");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query = '';
$run='';
for ($i = 0; $i < sizeof($placemarks); $i++) {
$coordinates = $placemarks[$i]->name;
$cor_d = explode(' ', $placemarks[$i]->Polygon->outerBoundaryIs->LinearRing->coordinates);
$qtmp=array();
foreach($cor_d as $value){
$tmp = explode(',',$value);
$ttmp=$tmp[1];
$tmp[1]=$tmp[0];
$tmp[0]=$ttmp;
$qtmp[]= '(' . $tmp[0] . ',' .$tmp[1].')';
}
$cor_d = json_encode($qtmp);
$query .='\''.$coordinates.'\', \''.$cor_d.'\'';
$run .="INSERT INTO jos_rpl_addon_zipinfo (name, boundary) VALUES (".$query." );";
//echo $run;
//break;
}
mysqli_query($con,$run);
//echo $run;
mysqli_close($con);
?>