SimpleXML如何获取具有属性First Name ==“John”的节点?可能没有循环?

时间:2013-05-04 13:10:47

标签: php xml simplexml

我是否必须遍历整个对象?

<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

0 个答案:

没有答案