2017-10-08 11 views
1

私はPS4ファームウェアのバージョンをXMLから取得しようとしていますが、何らかの理由でそれがNULLを返しています。SimpleXMLファームウェアのバージョンをXMLから取得

<?php 
    $list = simplexml_load_file('http://feu01.ps4.update.playstation.net/update/ps4/list/eu/ps4-updatelist.xml'); 

    if($list) { 
     echo $list->system_pup[0]['label']; // get firmware version 
    } else { 
     echo 'Error opening the XML file.'; 
    } 
?> 

私はthis articleを追ってきたし、私がそれを正しくやったようですので、私は、私が間違ってやっている見当がつかない。

アイデア?

答えて

3

間違った要素にアクセスすると、simplexmlはエラーをスローしません。エラーが発生しても、呼び出しから返された無駄はありません。あなたは構造体を見て、あなたの要素が構造体のどこにあるのかを判断する必要があります。この場合、1要素だけオフになります。

$list = simplexml_load_file('http://feu01.ps4.update.playstation.net/update/ps4/list/eu/ps4-updatelist.xml'); 
if($list) { 
    //print_r($list); 
    echo $list->region->system_pup[0]['label']; // get firmware version 
} else { 
    echo 'Error opening the XML file.'; 
} 
1

別のオプションは、にアクセスすることができることはattributes()機能を持つノードの属性:

$list = simplexml_load_file('http://feu01.ps4.update.playstation.net/update/ps4/list/eu/ps4-updatelist.xml'); 

echo $list->region->system_pup->attributes()->label; 
関連する問題