Posted in PHP onJune 17, 2010
/*获取图片新闻列表*/ function getPicNews($number=5){ require_once 'include/content_class.php'; $Content=new Content(); $sql='select contentid as id,title,pic,typeid from `cms_content` where pic<>"" order by input_time desc'; $rows=$Content->getRowsBySQL($sql,$number); $dom=new DOMDocument('1.0','GBK'); $root=$dom->createElement('slider'); $dom->appendChild($root); foreach($rows as $val){ $item=$dom->createElement('item'); $root->appendChild($item); $title=$dom->createAttribute('title'); $title_text=$dom->createTextNode($val['title']); $title->appendChild($title_text); $item->appendChild($title); $href=$dom->createAttribute('href'); $href_text=$dom->createTextNode('show.php?newsid='.$val['id'].'&classid='.$val['typeid']); $href->appendChild($href_text); $item->appendChild($href); $imageurl=$dom->createAttribute('imageurl'); $imageurl_text=$dom->createTextNode($val['pic']); $imageurl->appendChild($imageurl_text); $item->appendChild($imageurl); } return $dom->saveXML(); }
PHP操作xml代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@