Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

New products from Linux central

this displays the new products from linux central

<?php
if( ! ($fp = fopen("http://linuxcentral.com/backend/lcnew.rdf" , "r" )) )
die("Couldn't open xml file!");
$item_counter = 0;
$in_item_tag = 0;
$linnew_current_tag_state = '';
$linnew_headline_data = array();
function startElementHandler( $parser, $element_name, $element_attribs )
{
global $item_counter;
global $in_item_tag;
global $linnew_current_tag_state;
global $linnew_headline_data;
if( $element_name == "ITEM" )
{
$in_item_tag = 1;
}
if( $in_item_tag == 1 )
{
$linnew_current_tag_state = $element_name;
}
else
{
$linnew_current_tag_state = '';
}
}
function endElementHandler( $parser, $element_name )
{
global $item_counter;
global $in_item_tag;
global $linnew_current_tag_state;
global $linnew_headline_data;
$linnew_current_tag_state = '';
if( $element_name == "ITEM" )
{
$item_counter++;
$in_item_tag = 0;
}
}
function characterDataHandler( $parser , $data )
{
global $item_counter;
global $in_item_tag;
global $linnew_current_tag_state;
global $linnew_headline_data;
if( $linnew_current_tag_state == '' || $in_item_tag == 0 )
return;
if( $linnew_current_tag_state == "TITLE" ) {
$linnew_headline_data[$item_counter]["title"] = $data;
}
if( $linnew_current_tag_state == "LINK" ) {
$linnew_headline_data[$item_counter]["link"] = $data;
}

}
if( !($xml_parser = xml_parser_create()) )
die("Couldn't create XML parser!");

xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler");
xml_set_character_data_handler( $xml_parser , "characterDataHandler" );
while( $data = fread($fp, 4096) )
{
if( !xml_parse($xml_parser, $data, feof($fp)) )
{
break; // get out of while loop if we're done with the file
}
}
xml_parser_free($xml_parser);
?>
<HTML>
<HEAD>
<TITLE>linuxcentral new products</TITLE>
</HEAD>

<BODY BGCOLOR="#ffffff">

<H3>Linux central new products</H3>
<BR>
<?php

for( $i=0 ; $i < $item_counter ; ++$i )
{
printf("<A HREF=\"%s\">%s</a><br>\n" , $linnew_headline_data[$i]["link"] ,
$linnew_headline_data[$i]["title"] );
}

?>

</BODY>
</HTML>

here is the script in action , linux central new products