Home arrow JavaScript arrow Page 5 - Revisited: Creating an XML Content Feed With PHP
JAVASCRIPT

Revisited: Creating an XML Content Feed With PHP


This article was originally published early this year and is one of our most popular articles, republished by popular demand. Have a read and you will see why...

Author Info:
By: Mitchell Harper
Rating: 3 stars3 stars3 stars3 stars3 stars / 9
October 28, 2002
TABLE OF CONTENTS:
  1. · Revisited: Creating an XML Content Feed With PHP
  2. · Why a content feed?
  3. · Creating a sample content feed
  4. · Creating a sample content feed (contd.)
  5. · Testing Our Content Feed
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Revisited: Creating an XML Content Feed With PHP - Testing Our Content Feed
(Page 5 of 6 )

Testing our content feed is simple. Firstly, make sure that the feed.php script is in an Apache aware directory on your web server. Next, create a new HTML file named test.html and save it in the same directory as the feed.php script (I will assume that you have saved it in the /php directory of your web servers root directory). Enter the following HTML into test.html:

<html>

<head>

<title> Joe Bloggs News Test </title>

</head>

<body bgcolor="#FFFFFF">

<h1>The Latest News</h1>

<script language="JavaScript" src="http://localhost/php/feed.php"></script>

</body>

</html>


Run test.html in your web browser. It should look like this:

Our content feed in action

If you have a registered domain name (such as mysite.com) that points to a web server running PHP and MySQL, then try creating the content database on that server. Upload the feed.php script too. While still keeping the test.html file on your local machine, replace its src attribute to point to the feed.php script on your web server. Run test.html in your browser and it should appear exactly as before.

What makes our content feed dynamic?

Many things. The fact that we have complete control over the feed.php script on our server means that we could change anything we liked in it (maybe to include a sponsors ad) and any sites that were already using our content feed wouldn’t have to do a thing to get the updated version of our content feed because it's retrieved from our server every time it's displayed on their site.

Also, whenever we add a new item to our articles table, it will appear at the top of the content feed. Let's try adding one now. Using the MySQL console application, enter the following query:

insert into articles values(0, 'MySQL Version 4 Released', 'Today, MysQL AB have released MySQL version 4. It comes packed with a number of new features including transactions and faster query execution plans');

Return to your browser and hit the refresh button. It should look like this:

Refreshing the page shows the new record

It's just as easy to remove items from our content feed using the MySQL delete command:

delete from articles where articleId < 3;

This would remove those articles whose articeId is less than three, thus leaving two news headlines in our feed:

Refreshing the page after the delete MySQL statement

So, as you can see, it doesn't matter whose using our content feed on their site: if they're using the <script src="..."> method to include the JavaScript generated by our feed.php script it in their pages, then any new records we add will automatically be visible in the content feed when it's refreshed in their browser.
blog comments powered by Disqus
JAVASCRIPT ARTICLES

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials