$xml = simplexml_load_file('a.xml');
print_r($xml);
出现在结果是:SimpleXMLElement Object ( [SecondHouse] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 217045 [userid] => jtzy [password] => 123456 [del] => 0 ) [House] => 3-2-2 [AddDate] => 2010-11-2 16:35:08 ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 217042 [userid] => jtzy [password] => 123456 [del] => 0 ) [House] => 3-2-1 [AddDate] => 2010-11-2 16:30:56 ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 217041 [userid] => jtzy [password] => 123456 [del] => 0 ) [House] => 2-2-1 [AddDate] => 2010-11-2 16:19:06 ) ) )  现我要取 [House]  [AddDate] 二个的值,并把这二个值放入二维数组中,怎么取呀,thanks

解决方案 »

  1.   

    $rss = simplexml_load_file("a.xml"); 
    print_r($rss);//此处打印是有值的,值为上面发的那些代码
    foreach ($rss as $item)
    {
      echo  $item['AddDate'] . "</br>"; // 这里什么也没输出
      

  2.   

    多谢三楼的,昨天你的那种方法已把问题处理好了,
    现是  simplexml_load_file 中,取到了值,可怎么放到数组中的问题,
      

  3.   

    你用domxml或者正则读出来不就行了么!!!方法参考昨天我给你的!
      

  4.   

    5楼的,用正则的问题,已弄好了,
    现问是的simplexml_load_file 这个方法取值的问题,$xml = simplexml_load_file('a.xml');
    print_r($xml);
    出现在结果是:SimpleXMLElement Object ( [SecondHouse] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 217045 [userid] => jtzy [password] => 123456 [del] => 0 ) [House] => 3-2-2 [AddDate] => 2010-11-2 16:35:08 ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 217042 [userid] => jtzy [password] => 123456 [del] => 0 ) [House] => 3-2-1 [AddDate] => 2010-11-2 16:30:56 ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 217041 [userid] => jtzy [password] => 123456 [del] => 0 ) [House] => 2-2-1 [AddDate] => 2010-11-2 16:19:06 ) ) )   现我要取 [House]  [AddDate] 二个的值,并把这二个值放入二维数组中,怎么取呀,thanks
      

  5.   

    $xml = simplexml_load_file('a.xml');
    foreach($xml->SecondHouse as $v)
    {
      echo $v->House.'<br/>';
      echo $v->AddDate.'<br/>';
    }
    可以了