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...
// 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( $fp, 8192 ) ) {
xml_parse( $xmlParser, $data, feof( $fp ) );
}
// Close file open handler
fclose( $fp );
// Free xml parser from memory
xml_parser_free( $xmlParser );