doushao1948 2017-10-08 15:48
浏览 45
已采纳

SimpleXML从XML获取固件版本

I'm trying to get the PS4 firmware version from their XML, but for some reason it's returning NULL.

<?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.';
    }
?>

I have no idea what I'm doing wrong, because I've followed this article and it seems I've done it correctly.

Any ideas?

  • 写回答

2条回答 默认 最新

  • duanjiu4498 2017-10-08 15:54
    关注

    If accessing the wrong element simplexml doesn't throw an error it just gives you the nothingness that your call returned. You should look at the structure to determine where in the structure your element is. In this case you are off by 1 element.

    $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条)

报告相同问题?