0

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>
        </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;
}
1
  • simple_html_dom is fast? compared to what? certainly not to any of the libxml based extensions PHP offers out of the box. Commented Dec 4, 2010 at 22:29

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.