小编jon*_*son的帖子

php Xpath返回:非对象

使用PHP XPath我在xml文件中搜索客户:

$this->xpath->query(/custumer/new[id="222"])->item(0)->nodeValue;
Run Code Online (Sandbox Code Playgroud)

但是如果这个客户在xml文件中不存在,我会收到错误:

Notice: Trying to get property of non-object in D:\www\test.php on line 17
Run Code Online (Sandbox Code Playgroud)

如何避免这个错误?

php xpath

1
推荐指数
1
解决办法
1663
查看次数

标签 统计

php ×1

xpath ×1