2012-03-21 3 views
0

나는 API를 구현하여 wikimapia 웹 사이트에서 데이터를 가져 오려고합니다. 값을 반복 할 때 "id"값만 반복합니다. 데이터를 얻기 위해 아래에있는 내 PHP 코드를 참조하십시오xml 값 반복 (wikimapia)

<?php 

$url = ("http://api.wikimapia.org/?function=search&key=****&q=buildings&lat=51.5424&lon=-0.1734&count=20&page=1"); 

$xml = simplexml_load_file($url); 

foreach ($xml->place as $entry) { 

echo $entry->attributes()->id; 
echo $entry->attributes()->name; 
echo $entry->attributes()->url; 
echo $entry->attributes()->lat; 
echo $entry->attributes()->lon; 

} 
// Process XML file 

?> 

는 웹 사이트에서 XML 구조의 발췌를 보자 :

<?xml version="1.0" encoding="utf-8"?> 
<?access-control allow="*"?> 
<folder language="en" version="1.0" found="87" page="1" count="20"> 
<place id="18508464"> 
<name>Miles Buildings</name> 
<url>http://wikimapia.org/18508464/Miles-Buildings</url> 
<location> 
<lon>-0.1703605</lon> 
<lat>51.5211928</lat> 
<north>51.5218053</north> 
<south>51.5205803</south> 
<east>-0.1696712</east> 
<west>-0.1710498</west> 
</location> 
<polygon> 
<point x="-0.1699769" y="51.5218053"/> 
<point x="-0.1696712" y="51.5214648"/> 
<point x="-0.1703846" y="51.5211177"/> 
<point x="-0.1699823" y="51.5206971"/> 
<point x="-0.1703203" y="51.5205803"/> 
<point x="-0.1708031" y="51.5209341"/> 
<point x="-0.1707333" y="51.5209741"/> 
<point x="-0.1710498" y="51.5212812"/> 
</polygon> 
</place> 
</folder> 

을 내가 잘못 뭐하는 거지? 감사합니다. .

답변

0

폴더 속성은 다음과 같습니다

language="en" version="1.0" found="87" page="1" count="20" 

다른있는 자식 노드를, 당신이

+0

그것은 출력은 무엇입니까 – akinboj

+0

가 해결되지 않는 무엇을 얻을 볼 print_r($xml);를 사용하려고? – alvariux

+0

@ alvariux : 노드 출력 편집을 참조하십시오. – akinboj