$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
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
解决方案 »
- PHP程序中怎么设置session.save_path为注释
- php字符串截取,取“整”字问题
- 一条INSERT语句求助!我在MYSQL5.0下好用!可是mysql4下就报错了!
- 在ajax中用POST方法提交的XML串,服务器端如何回显到客户端?
- 帮解释一下排序函数啊
- 请问如何使用Smarty中的缓存功能?分不多,在线等!
- php5出现:using $this when not in object
- 模糊搜索,为何那么不准确?
- 怎么有odbc分页(数据库是ACCESS的)。请高手指点。谢谢各位。
- 网站出问题了,/brand/?do=xxx 可以访问 /brand?do=xxx 也能访问,我要控制后面的不能访问,怎么弄?
- PHP 内容保存程序代码
- simplexml_load_file 函数用不的问题,
print_r($rss);//此处打印是有值的,值为上面发的那些代码
foreach ($rss as $item)
{
echo $item['AddDate'] . "</br>"; // 这里什么也没输出}
现是 simplexml_load_file 中,取到了值,可怎么放到数组中的问题,
现问是的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
foreach($xml->SecondHouse as $v)
{
echo $v->House.'<br/>';
echo $v->AddDate.'<br/>';
}
可以了