在数组中存储XML [关闭]

here is link to i want to convert xml to array
http://services.gisgraphy.com/geoloc/search?lat=22.298569900000000000&lng=70.794301799999970000&radius=7000
click on above link its return one XML file
i want to store it on array
please help...
thanks

Just a small note.. to convert into array is easy as casting (array)

$xml = file_get_contents('http://services.gisgraphy.com/geoloc/search?lat=22.298569900000000000&lng=70.794301799999970000&radius=7000', true);
$xml = (array)simplexml_load_string($xml);
print_r($xml);

You can use simplexml_load_string of php

For example:

<?php
$string = <<<XML
<?xml version='1.0'?> 
<document>
 <title>Forty What?</title>
 <from>Joe</from>
 <to>Jane</to>
 <body>
  I know that's the answer -- but what's the question?
 </body>
</document>
XML;

$xml = simplexml_load_string($string);

print_r($xml);
?>

Output

SimpleXMLElement Object
(
  [title] => Forty What?
  [from] => Joe
  [to] => Jane
  [body] =>
   I know that's the answer -- but what's the question?
)

Read http://php.net/manual/en/function.simplexml-load-string.php for more info.

Also you can use https://github.com/gaarf/XML-string-to-PHP-array/blob/master/xmlstr_to_array.php

You have to fetch it and than convert in to simple xml object.

$responce = file_get_contents('http://services.gisgraphy.com/geoloc/search?lat=22.298569900000000000&lng=70.794301799999970000&radius=7000', true); print_r(simplexml_load_string($responce));