Rss subscription using xml

Source: Internet
Author: User
RSS is a combination of webpage content and XML. All RSS documents comply with the XML1.0 standard. RSS is a combination of webpage content and XML. All RSS documents comply with the XML1.0 standard.

Example:

   
          
                  
   Title                
   Link address                
   
    
Description
                   
   
    
Description Language
                   
   
    
Version
                   
   
    
Time
                   
                          
    Log title                    
    Log urlLog author                       
    
     
Log release time
                           
    
     
Log content
                    
            
    
 

At this time, you should link to the database and output the desired results.

Test. PHP

 Dom = new domDocument ('1. 0', 'utf-8'); $ this-> dom-> load ($ this-> template ); $ this-> rss = $ this-> dom-> GetElementsByTagName ('RSS ');} public functioncreateChannel () {$ channel = $ this-> dom-> createElement ("channel"); $ channel-> appendChild ($ this-> createEle ('title ', $ this-> title); $ channel-> appendChild ($ this-> createEle ('link', $ this-> link )); $ channel-> appendChild ($ this-> createEle ('Description', $ this-> description); $ this-> rss-> appendChild ($ channel );} public functioncreateEle ($ name, $ value) {$ element = $ this-> dom-> createElement ($ name ); $ text = $ this-> dom-> createTextNode ($ value); $ element-> appendChild ($ text); return $ element;} protected functionadditem ($ list) {foreach ($ listas $ goods) {$ this-> rss-> appendChild ($ this-> createitem ($ goods);} public functioncreateitem ($ arr) {$ item = $ this-> dom-> createElement ("item"); foreach ($ arras $ key => $ value) {$ item-> appendChild ($ this-> createEle ($ key, $ value);} return $ item;} public functiondisplay () {$ this-> createChannel (); $ this-> additem ($ this-> items); echo $ this-> dom-> savexml () ;}$ SQL = "select * fromstu "; $ rs = mysql_query ($ SQL); while ($ row = mysql_fetch_assoc ($ rs) {$ list [] = $ row;} $ test = new test (); $ test-> title = "test title"; $ test-> link = "test connection"; $ test-> description = "test content "; $ test-> display (); $ test-> items = $ list;

The above is the details of rss subscription using xml. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.