Please see below. I have posted the entire script. "Bogdan Stancescu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > Then you're doing something wrong. Can you post a piece of code? > > Bogdan > > Erich Kolb wrote: > > I have already downloaded the entire file so that Im not constantly > > accessing FreshMeat.net's servers. I will be processing the update files as > > soon as I can get the big one done. > > I have also tried to use htmlspecialchars, and nl2br, but it doesnt look > > like there is any output to process. > > > > "Bogdan Stancescu" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED]... > > > >>Hi! > >> > >>You can get the content of that file with php, using <? > >>$projects_rdf=file("http://www.freshmeat.net/backend/fm-projects.rdf"); > >>?> - then you can do whatever you please with it. Make sure to > >>htmlspecialchars() it before outputting to a browser - and consider a > >>nl2br() while you're at it as well. > >> > >>Please be warned that it's a huge download though - you may consider > >>only downloading the updates, available from freshmeat from another > >>location (I'm sure you can find it easily, I don't have the link at hand). > >> > >>HTH > >> > >>Bogdan > >> > >>Erich Kolb wrote: > >> > >>>I am trying to write a script that will take a look at the freshmeat.net > >>>database (http://www.freshmeat.net/backend/fm-projects.rdf), parse the > >> > > file, > > > >>>and insert it into a MySQL DB. I have already wrote one for > >> > > slashdot.org > > > >>>that puts the output into html and displays it in a web browser and it > >> > > works > > > >>>fine. I am trying to do the same to start with for freshmeat (I am > >> > > learning > > > >>>as I go) but there is nothing displayed on the browser. Can someone > >> > > help me > > > >>>out with this? > >>> > >>>Here is the code I have written for slashdot: > >>><?php > >>> > >>>$insideitem = false; > >>>$tag = ""; > >>>$title = ""; > >>>$description = ""; > >>>$link = ""; > >>> > >>>function startElement($parser, $name, $attrs) { > >>> global $insideitem, $tag, $title, $description, $link; > >>> if ($insideitem) { > >>> $tag = $name; > >>> } elseif ($name == "STORY") { > >>> $insideitem = true; > >>> } > >>>} > >>> > >>>function endElement($parser, $name) { > >>> global $insideitem, $tag, $title, $description, $link; > >>> if ($name == "STORY") { > >>> printf("<dt><b><a href='%s'>%s</a></b></dt>", > >>> trim($description),htmlspecialchars(trim($title))); > >>> #printf("<dd>%s</dd>",htmlspecialchars(trim($description))); > >>> $title = ""; > >>> $description = ""; > >>> $link = ""; > >>> $insideitem = false; > >>> } > >>>} > >>> > >>>function characterData($parser, $data) { > >>> global $insideitem, $tag, $title, $description, $link; > >>> if ($insideitem) { > >>> switch ($tag) { > >>> case "TITLE": > >>> $title .= $data; > >>> break; > >>> case "URL": > >>> $description .= $data; > >>> break; > >>> } > >>> } > >>>} > >>> > >>>$xml_parser = xml_parser_create(); > >>>xml_set_element_handler($xml_parser, "startElement", "endElement"); > >>>xml_set_character_data_handler($xml_parser, "characterData"); > >>>$fp = fopen("http://www.slashdot.org/slashdot.xml","r") > >>> or die("Error reading RSS data."); > >>>while ($data = fread($fp, 4096)) > >>> xml_parse($xml_parser, $data, feof($fp)) > >>> or die(sprintf("XML error: %s at line %d", > >>> xml_error_string(xml_get_error_code($xml_parser)), > >>> xml_get_current_line_number($xml_parser))); > >>>fclose($fp); > >>>xml_parser_free($xml_parser); > >>> > >>>?> > >>> > >>>And here is what I have so far for FreshMeat.net. Its pretty much the > >> > > same, > > > >>>but the elements are a little different: > >>><?php > >>> > >>>$insideitem = false; > >>>$tag = ""; > >>>$project_id = ""; > >>>$date_added = ""; > >>>$date_updated = ""; > >>>$projectname_short = ""; > >>>$projectname_full = ""; > >>>$desc_short = ""; > >>>$desc_full = ""; > >>>$url_homepage = ""; > >>> > >>>function startElement($parser, $name, $attrs){ > >>>global $insideitem, $tag, $project_id, $date_added, $date_updated, > >>>$projectname_short, $projectname_full, $desc_short, $desc_full, > >>>$url_homepage; > >>> if($insideitem){ > >>> $tag = $name; > >>> } > >>> elseif ($name == "project"){ > >>> $insideitem = true; > >>> } > >>>} > >>> > >>>function characterData($parser, $data){ > >>>global $insideitem, $tag, $project_id, $date_added, $date_updated, > >>>$projectname_short, $projectname_full, $desc_short, $desc_full, > >>>$url_homepage; > >>> if($insideitem){ > >>> switch ($tag){ > >>> case "project_id": > >>> $project_id .=$data; > >>> break; > >>> > >>> case "date_added": > >>> $date_added .=$data; > >>> break; > >>> > >>> case "date_updated": > >>> $date_updated .=$data; > >>> break; > >>> > >>> case "projectname_short": > >>> $projectname_short .=$data; > >>> break; > >>> > >>> case "projectname_full": > >>> $projectname_full .=$data; > >>> break; > >>> > >>> case "desc_short": > >>> $desc_short .=$data; > >>> break; > >>> > >>> case "desc_full": > >>> $desc_full .=$data; > >>> break; > >>> > >>> case "url_homepage": > >>> $url_homepage .=$data; > >>> break; > >>> } > >>> } > >>> } > >>> > >>>function endElement($parser, $name){ > >>>global $insideitem, $tag, $project_id, $date_added, $date_updated, > >>>$projectname_short, $projectname_full, $desc_short, $desc_full, > >>>$url_homepage; > >>>if ($name =="project"){ > >>> echo trim($projectname_full)."\n"; > >>> echo trim($url_homepage)."\n"; > >>> $projectname_full =""; > >>> $url_homepage =""; > >>> } > >>>} > >>> > >>> > >>>$xml_parser = xml_parser_create(); > >>>xml_set_element_handler($xml_parser, "startElement", "endElement"); > >>>xml_set_character_data_handler($xml_parser, "characterData"); > >>>$fp = fopen("fm-projects.rdf","r") > >>> or die("Error reading RSS data."); > >>>while ($data = fread($fp, 4096)) > >>> xml_parse($xml_parser, $data, feof($fp)) > >>> or die(sprintf("XML error: %s at line %d", > >>> xml_error_string(xml_get_error_code($xml_parser)), > >>> xml_get_current_line_number($xml_parser))); > >>> > >>> > >>>fclose($fp); > >>>xml_parser_free($xml_parser); > >>> > >>> > >>>?> > >>> > >>> > >>> > > > > > >
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php