2013-03-23 3 views

ответ

2

Просто небольшая заметка .. преобразовать в массив легко, как литье (массив)

$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); 
2

Вы можете использовать simplexml_load_string из php

Для Например:

<?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); 
?> 

Выход

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

Читать http://php.net/manual/en/function.simplexml-load-string.php для получения дополнительной информации.

Также вы можете использовать https://github.com/gaarf/XML-string-to-PHP-array/blob/master/xmlstr_to_array.php

Смежные вопросы