我必须遍历整个对象吗?
<Employees>
<Employee name="John"> ... </Employee>
<Employee name="Will"> ... </Employee>
<Employee name="Jack"> ... </Employee>
</Employees>
我正在使用以下方法读取 XML 文件:
$employees = simplexml_load_file($xmlfile);
$str = "John";
//find node with name matching $str assign it as $emp
$emp = $employees->Employee['name='.$str]; //my attempt