2014-04-17 2 views
0

에 따옴표를 처리하는 데 실패 : 브라우저 모두와 견적을 포함PHP DOMDocument를 내가 그와 같은 URL을 열려고 할 때 URL

http://api.anghami.com/rest/v1/GETsearch.view?sid=11754134061397734622103190992&query=Can't Remember to Forget You Shakira&searchtype=SONG&ook&songCount=1 

잘 작동하고 출력은 XML

좋은입니다 나는 PHP 파일에서 호출하려고 할 때 :

'Warning: DOMDocument::load(): I/O warning : failed to load external entity /var/www/html/http:/api.anghami.com/rest/v1/GETsearch.view?sid=11754134061397734622103190992&query=Can't Remember to Forget You Shakira&searchtype=SONG&ook&songCount=1" in /var/www/html/search.php on line 93' 
:

 $url = "http:/api.anghami.com/rest/v1/GETsearch.view?sid=11754134061397734622103190992&query=Can't Remember to Forget You Shakira&searchtype=SONG&ook&songCount=1" 

//using DOMDocument for parsing. 
$data = new DOMDocument(); 

// loading the xml from Anghami API. 
if($data->load("$url")){// Getting the Tag song. 

foreach ($data->getElementsByTagName('song') as $searchNode) 
     { 
     $count++; 
     $n++; 
     //Getting the information of Anghami Song from the XML file. 
     $valueID = $searchNode->getAttribute('id'); 
    $titleAnghami = $searchNode->getAttribute('title'); 
    $album = $searchNode->getAttribute('album'); 
    $albumID = $searchNode->getAttribute('albumID'); 
    $artistAnghami = $searchNode->getAttribute('artist'); 
    $track = $searchNode->getAttribute('track'); 
    $year = $searchNode->getAttribute('year'); 
    $coverArt = $searchNode->getAttribute('coverArt'); 
    $ArtistArt = $searchNode->getAttribute('ArtistArt'); 
    $size = $searchNode->getAttribute('size'); 
    } 
} 

나는이 오류

아무도 도와 줄 수 있습니까?

+1

'$ url'의'http : /'대신'http : //' – Fracsi

+0

다음 url로 시도하십시오 :'http://api.anghami.com/rest/v1/GETsearch.view?sid=11754134061397734622103190992&query= % 27 % 20 % 20 % 20 % 20 % 20 % 20 % 20 % 20 % 할인 20 % 할인 20 % 할인 20 % 할인 & SONAC & OOK & SongCount = 1' –

+0

URL은 http : // ... 문제가되지 않습니다. –

답변

0

@Fracsi가 정확한지 : URL이 http://로 시작해야하지 http:/

다른 문제 XML은 (루트 요소에 xmlns 속성으로 정의) 기본 네임 스페이스를 가지고, 그래서 당신이 사용할 필요가있다

$data->getElementsByTagNameNS('http://api.anghami.com/rest/v1', 'song') 

모든 "노래"요소를 선택하십시오.

관련 문제