$dom=new DOMDocument('1.0');
$dom->load('ceshi.xml');
$root=$dom->getElementsByTagName('online');
$root=$root->item(0);
$userid=$root->getElementsByTagName('userid');
foreach($userid as $b)
{
  foreach($b->attributes as $attr){ $value=$attr->nodeValue;
$name[].=$attr->nodeName;
{if($value=="xiao")
{  
   print_r($name);   } }
}}
$dom->save('ceshi.xml'); 
 
来个xml
<?xml version="1.0"?>
<online> 
<userid time="2007-06-13 11:20:08" ip="wangqile" label="wang">xiaxin</userid> 
<userid time="2007-06-13 13:22:15" pp="dasdsa" label="xiao" ip="dasdsa">rwet</userid> 
<userid time="2007-06-13 17:17:00" ip="dasdsa" label="ji"> gaoji</userid> 
</online>
问题是按上面那种写法只循环label="xiao"的那一行,也就是只返回那一行nodename值。。
要是按上面写的话返回的是第一行第二行一起返回的nodename值。。我也没想出来怎么改~~新手求教啊!!!