Cell Phone Picker

Latest Cell Phone News

$errortitle"; $title = ""; $link = ""; $description = ""; } } // close the file handle fclose($fp); } // Change this to the URL of your RSS file // ############################################ $rssurl = "http://www.mobiledia.com/rss/news/"; $rssur2 = "http://crave.cnet.com/8300-1_105-1-0.xml?categoryId=1006&tag=sb_cat&keywords=Phones"; // ############################################ // if there is a parse error display the following generic // title and link rather than a cryptic numeric XML error // change title and URL to suit your site // ########################################### $errortitle = "Phone Picker"; $errorurl = "http://www.phonepicker.com/"; // ########################################### // startElement is function called when the parser encounters a new element // startElement function basically ignores starting elements until // it finds an ITEM element, once inside an function startElement($parser, $name, $attrs) { global $insideitem, $numitems, $tag, $title, $description, $link; if ($insideitem) { $tag = $name; } elseif ($name == "ITEM") { // we are now inside an item tag so set $insideitem to true // and increment $numitems $insideitem = true; $numitems++; } } // endElement is function called when the parser encounters an ending element // endElement just needs to reset $insideitem variable when it sees // because the parser is no longer inside an item tag function endElement($parser, $name) { global $insideitem, $numitems, $tag, $title, $description, $link; if ($name == "ITEM") { $insideitem = false; } } // characterData is where the work is done // when we are inside an ITEM element build an array of headlines // with links and descriptions function characterData($parser, $data) { global $insideitem, $numitems, $tag, $title, $description, $link; // if we are inside an item tag build up the arrays of headline // information if ($insideitem) { switch ($tag) { case "TITLE": $title[$numitems] .= $data; break; case "DESCRIPTION": $description[$numitems] .= $data; break; case "LINK": $link[$numitems] .= $data; break; } } } // Here is where the work is done and the preceding functions // are called // Create parser and register functions $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); // open rss file $fp = fopen("$rssurl","r") or die("Error reading RSS data."); // do the parsing // note that if there is an error it will display the $errortitle set // above with a link or $errorurl parseRssFile($xml_parser, $fp, $errorurl, $errortitle); xml_parser_free($xml_parser); // If parsing was successful we have three arrays // $headlines contains the headline text // $link contains the URLs for the headlines // $description contain the descriptions for each headline // The following for loop will print elements from the array // Several modifications can be made to the loop // The example below will only print the first 6 headlines from the // RSS file (6 elements from the array) // if you want to print all elements from the array change // $j<=6 to $j<=count($title) // Also the for loop below does not print descriptions // If your channel also contains descriptions you might want to // print them as well by trying the following print statement in the loop // instead of the one that is there: // print "

$title[$j]
$description[$j]

\n"; // unroll array printing out links to headlines for ($j=1; $j<=10; $j++) { print "

$title[$j]

$description[$j]

\n"; } // end script ?>

Site Map | Contact Us | Privacy Policy | ©2007-2008 phonepicker.com