使用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)
如何避免这个错误?