您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

读取xml数据之后smarty的模板应该如何写

2025/3/16 17:36:42发布13次查看
读取xml数据之后smarty的模板应该怎么写
header(content-type:text/html; charset=utf-8);
$url = http://www.hnta.cn/apis/api_get_newslist.asp?m=1&cid=j162hhc8824h&page=1&pagesize=2;
$xml=simplexml_load_file($url); //将xml中的数据,读取到数组对象中
foreach($xml as $tmp){
//echo $tmp->title.-.$tmp->url.
;
}
$qf->assign('xml',$xml);
{foreach from=$xml item=list}
{$list.title} |
{/foreach}

php代码没有问题,echo的话输出一切正常。
但是模板只输出了两个“|”符号,没有把数据给输出出来。
分享到: 更多
------解决方案--------------------
simplexmlelement object
(
    [@attributes] => array
        (
            [page] => 1
            [pagesize] => 2
            [recordcount] => 13995
        )
[news] => array
        (
            [0] => simplexmlelement object
                (
                    [@attributes] => array
                        (
                            [classid] => j162hhc8824h
                            [classname] => 地市信息
                        )
[id] => 37169
                    [title] => 漯河市旅游局部署全市旅游安全工作
                    [pic] => simplexmlelement object
                        (
                        )
[url] => /gov/citynews/2014-01/14135379937.shtml
                    [addtime] => 2014/1/14 10:19:38
                )
[1] => simplexmlelement object
                (
                    [@attributes] => array
                        (
                            [classid] => j162hhc8824h
                            [classname] => 地市信息
                        )
[id] => 37168
                    [title] => 三门峡市旅游局深入学习贯彻三门峡市委六届五次全会精神

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product