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

报告相同问题?

悬赏问题

  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块
  • ¥15 nhanes加权logistic回归,svyglm函数