Hi friends, in this post i am going to explain about how to convert feeds to html using javascript and php. Just provide feed url and get the list of entries and description from the feeds. In my previous post explained about steps to implement and hosting your website in google app engine for free.I have placed the Javascript code in google app engine hosted site.

How to convert feeds to html using javascript and php by Anil Kumar Panigrahi

How to convert feeds to html using javascript and php by Anil Kumar Panigrahi

demo link for how to convert feeds to html using javascript and php download link for how to convert feeds to html using javascript and php

 
Here i will explain how to get the entries with dynamic styles. In have created this post with using my previous posts.

1) How to get links from feed using php

http://www.anillabs.com/2009/12/how-to-get-links-from-feed-using-php/
 

2) How to clean a string using php code

http://www.anillabs.com/2010/02/how-to-clean-a-string-using-php-code/
 

3) How to create rss feeds using php and mysql

http://www.anillabs.com/2010/07/how-to-create-rss-feeds-using-php-and-mysql/
 

4)Examples for PHP Headers (301,302,404,…)

http://www.anillabs.com/2011/04/examples-for-php-headers-301302404/
 

5)how to include external js,css files with javascript

http://www.anillabs.com/2010/09/how-to-include-external-jscss-files-with-javascript/
 
In some servers DOMDocument(); is not working. For this we have to change the code like below
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  <?php
       // initialize a new curl resource
       $ch = curl_init();
       // set the url to fetch
       curl_setopt($ch, CURLOPT_URL, $xml);
       // don't give me the headers just the content
       curl_setopt($ch, CURLOPT_HEADER, 0);
       // return the value instead of printing the response to browser
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       // use a user agent to mimic a browser
       curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
       $details = curl_exec($ch);
       // remember to always close the session and free all resources
       curl_close($ch);
  ?>

I have explained in the demo. Provide the feed url and font-size and get the javascript code. Place it in your html page.

 


3 Comments

Kathir Maya · October 28, 2011 at 6:17 am

nice work 🙂

ReSAprakasa · November 14, 2011 at 12:33 pm

welldone

Marcos · November 14, 2011 at 2:06 pm

You can do the opposite?
Transform HTML in JavaScript?

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *