RSS efficient i...login
RSS efficient introductory tutorial
author:php.cn  update time:2022-04-11 14:48:25

RSS example


These examples use our RSS reader to demonstrate RSS.

RSS <channel> element

Set the required options of the channel element (<title>, <link>, and <description>)

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
</channel>
</rss>

Run instance»

Click the "Run instance" button to view the online instance

Specify category for RSS

Instance

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <category>IT/Internet/Web development</category>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <category>News</category>
    <category>Tutorial</category>
  </item>
</channel>
</rss>

Run Instance»

Click the "Run Instance" button to view the online instance

Specify the content used to generate RSS Program

Instance

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <generator>Notepad</generator>
    <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

Run instance»

Click the "Run instance" button to view the online instance

Specify image for RSS

Instance

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <image>
    <url>http://www.w3cschool.cc/images/logo.png</url>
    <title>W3Cschool.cc</title>
    <link>http://www.w3cschool.cc</link>
  </image>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

Run instance»

Click the "Run instance" button to view Online Example

Specify language for RSS

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <language>en-us</language>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

Run Example»

Click the "Run Example" button to view the online example

Add text input box for RSS

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <textinput>
    <description>Search Google</description>
    <title>Search</title>
    <link>http://www.google.no/search?</link>
    <name>q</name>
  </textinput>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

Run Instance»

Click the "Run Instance" button to view the online instance

Specify the days when RSS does not need to be updated

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <skipDays>
    <day>Saturday</day>
    <day>Sunday</day>
  </skipDays>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

Run instance»

Click the "Run instance" button to view the online instance

Instance analysis

RSS <item> Element

Set required options (<title>, <link>, and <description>)

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>http://www.w3cschool.cc/xml</link>
    <description>New XML tutorial on W3Cschool</description>
  </item>
</channel>
</rss>

Run Example»

Click the "Run Example" button to view the online example

Add a comment link to the RSS item

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <comments>http://www.w3cschool.cc/rss/comments.php</comments>
  </item>
</channel>
</rss>

Run Example»

Click the "Run Example" button to view the online example

Add media files to the RSS project

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <enclosure url="http://www.w3cschool.cc/media/3d.wmv"
    length="78645" type="video/wmv" />
  </item>
</channel>
</rss>

Run instance»

Click the "Run instance" button to view the online instance

Add a unique identifier to the project

Instance

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <guid>http://www.w3cschool.cc/rss/item0768</guid>
  </item>
</channel>
</rss>

Run Instance»

Click the "Run Instance" button to view the online instance

Add publishing information to the RSS project

Instance

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <pubDate>Thu, 27 Apr 2006</pubDate>
  </item>
</channel>
</rss>

Run instance»

Click the "Run instance" button to view online Example

Add a third party to the RSS project

Example

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<rss version="2.0">
<channel>
  <title>W3Cschool Home Page</title>
  <link>http://www.w3cschool.cc</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3cschool.cc/rss</link>
    <description>New RSS tutorial on W3Cschool</description>
    <source url="http://www.w3cschool.cc">W3Cschool.cc</source>
  </item>
</channel>
</rss>

Run the example»

Click the "Run Instance" button to view the online instance

Instance analysis

php.cn