The following code is the function code for obtaining the Image news list. it contains the core code for operating the xml file. For more information, see.
The code is as follows:
/* Obtain the image News list */
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 ();
}