xml文件:
 <activities>
    <act id="act_11" type="1" status="1">
      <date>2011/06/01-2011/12/02</date>
      <time>02:12-23:23</time>
      <link>
        <![CDATA[<a href="http://www.my4399.com">4399大活动开始喽</a>]]>
      </link>
    </act>
    <act id="act_12" type="3" status="0">
      <date>2011/06/01-2011/12/12</date>
      <time>00:00-23:23</time>
      <link>
        <![CDATA[<a href="http://www.163.com">121333</a>]]>
      </link>
    </act>
    <act id="act_12" type="1" status="0">
      <date>2011/06/01-2011/12/12</date>
      <time>00:00-23:23</time>
      <link>
        <![CDATA[<a href="http://www.163.com">121</a>]]>
      </link>
    </act>
  </activities>
$xml = new DOMDocument(); 
$xml->load('1.xml');
$act = $xml->getElementsByTagName('act');
上面这句只取出了所有act节点的集合
我要取出act所有节点中满足属性type="1"的,请问怎么弄呢?谢谢!

解决方案 »

  1.   

    $act = $xml->getElementsByTagName('act')->item(2);
    $act->parentNode->removeChild($act);
    这样不能删除第三条act,不知道是为什么呢?
      

  2.   

    上面这句只取出了所有act节点的集合
    我要取出act所有节点中满足属性type="1"的,请问怎么弄呢?谢谢!遍历,然后判断 type 属性是否等于 1