from xml to php array,Infinite loops
i wish export data from xml file to array.
(i know simple_html_dom is very fast - so use it). Why always is Infinite loops?
<Response>
<Placemark id="12">
<address>LA 3, NY, USA</address>
<Details>data1</Details>
<Point>
<coordinates1>-73.5850086,40.7207442,0</coordinates1>
<coordinates2>73.5850086,-40.7207442,0</coordinates2>
&开发者_如何学编程lt;/Point>
</Placemark>
<Placemark id="15">
<address>LA 4, NY2, USA</address>
<Details>data2</Details>
<Point>
<coordinates1>-71.5850086,22.7247442,0</coordinates1>
<coordinates2>71.5850086,-22.7247442,0</coordinates2>
</Point>
</Placemark>
</Response>
include('simple_html_dom.php');
$url = 'test.xml';
$xml = file_get_html($url);
$res = array();
foreach($xml->find('Response') as $e)
{
$res[] = $e;
}
I don't know about simple_html_dom
, but for parsing that XML you should be fine using the SimpleXML
API.
<?php
$xml = simplexml_load_file('test.xml');
echo $xml->Placemark[0]->address;
?>
Outputs: LA 3, NY, USA
精彩评论