How to convert feeds to html using javascript and php

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
 

  <?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.

 

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online

Contact : [email protected]

You may also like...

3 Responses

  1. ReSAprakasa says:

    welldone

  2. Marcos says:

    You can do the opposite?
    Transform HTML in JavaScript?

Leave a Reply

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