Current location: Hot Scripts Forums » Programming Languages » PHP » Read XML-RSS file from PHP?


Read XML-RSS file from PHP?

Reply
  #1 (permalink)  
Old 11-20-06, 07:48 AM
Anisking Anisking is offline
Newbie Coder
 
Join Date: Sep 2006
Location: Chennai
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Question Read XML-RSS file from PHP?

Hai everybody,
pls,tel me about php code to read XML-RSS file from other site,
and if i read this file can i see that with application format ie., as it like a webpage.?

Note: here i show my code which is doing read the file only but it couldn't display that links and description with application format or like webpage.
Please gothrough it and tel ur suggestion...

PHP Code:

  function startElement$parser$tagName$attrs 
  {
    echo 
"<"strtolower$tagName ) . ">";    
  }
 
  
// function: endElement
  // Deals with the ending element
  
function endElement$parser$tagName )
   {
    echo 
"</" strtolower$tagName ) ."><br>";
  }
 
  
// function: charElement
  // Deals with the text in between tags
  
function charElement$parser$text 
  {
    echo 
"$text";
  }
 
  
// Create an xml parser
  
$xmlParser xml_parser_create();
 
  
// Set up element handler
  
xml_set_element_handler$xmlParser"startElement""endElement" );
 
  
// Set up character handler
  
xml_set_character_data_handler$xmlParser"charElement" );
 
  
// Open connection to RSS XML file for parsing.
  
echo "<img src='http://www.hindu.com/thehindu/hindux.gif' width='468' height='50'>";
  
$fp fopen"http://www.hindu.com/rss/23hdline.xml""r" )
    or die( 
"Cannot read RSS data file." );// http://www.hindu.com/rss/07hdline.xml
 
  // Parse XML data from RSS file.
  
while( $data fread$fp8192 ) ) {
    
xml_parse$xmlParser$datafeof$fp ) );
  }
 
  
// Close file open handler
  
fclose$fp );
 
  
// Free xml parser from memory
  
xml_parser_free$xmlParser ); 
Reply With Quote
  #2 (permalink)  
Old 11-20-06, 08:02 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
such script have allready been built. i suggest to use one of them.
here you can find plenty of classes, which will parse the rss for you

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code 2 convert .doc file into .pdf file jeephp PHP 7 11-03-10 04:31 AM
Write in a XML file with php pallabmondal123 PHP 2 04-15-06 05:34 AM
PHP - Unable to remove items from a file AdrianLewis PHP 5 03-17-06 05:14 AM
perl dates (for rss feed) gnznroses Perl 4 11-28-05 01:44 PM
Saving php generated file as html file GS300 PHP 0 12-29-04 03:34 AM


All times are GMT -5. The time now is 05:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.