Posted By

mail_json on 07/16/06


Tagged

rss


Versions (?)

Who likes this?

19 people have marked this snippet as a favorite

meth
1man
Ernstladen
dmarten
matt
vali29
hudge
JimiJay
czapata
cristianciofu
mb
nb109
vehler
bobbym245
ninjacharlee
muzafarova
wirenaught
robfahy
ringo380


RSS


 / Published in: PHP
 

  1. <?php
  2. $file="http://news.bbc.co.uk/rss/newsonline_world_edition/business/rss.xml <http://news.bbc.co.uk/rss/newsonline_world_edition/business/rss.xml>
  3. ";
  4. $data=implode("",file($file));
  5. $parser = xml_parser_create();
  6. xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  7. xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  8. $val= xml_parse_into_struct($parser, $data,$values,$tags);
  9. //echo $val;
  10. xml_parser_free($parser);
  11. $title=array();
  12. $link=array();
  13. $descriptionfiltered=array();
  14. $primarycount="0";
  15. $counter="0";
  16. $count1="0";
  17. ?>
  18. <!--<pre>-->
  19. <?php
  20. //print_r($values);
  21. foreach($values as $key=>$val)
  22. {
  23. foreach($val as $key1=>$val1)
  24. {
  25.  
  26. //echo $val1."hjgjhg";
  27. if($key1=="tag")
  28. {
  29. if($val1=="item")
  30. {
  31. $primarycount++;
  32.  
  33. if($primarycount%2!=0)
  34. {
  35. $counter++;
  36. $count1=$count1+1;
  37. }
  38.  
  39. }
  40. //print_r($value);
  41. if($val1=="title")
  42. {
  43. $title[$counter]=$val['value'];
  44. //echo "test".$title[$counter]."ok";
  45. }
  46. if($val1=="link")
  47. {
  48. $link[$counter]=$val['value'];
  49. $count1=0;
  50. }
  51. if($val1=="description")
  52. {
  53. $description[$counter]=$val['value'];
  54. $count1++;
  55. }
  56. }
  57. }
  58. }
  59.  
  60. ?>
  61. <table>
  62. <tr>
  63. <td>
  64.  
  65. <?
  66. for($i=0;$i<count($title);$i++)
  67. {
  68. ?>
  69. <table border="0">
  70. <tr><td class="bdytxt4"><b><?=$title[$i];?></b></td></tr>
  71. <tr><td class="bdytxt"><?=$description[$i];?></font></td></tr>
  72. <tr><td><a href=http://mail.yahoo.com/config/login?/"<?=$link[$i];?>"><font
  73. color="#0099FF">more..</font></a></td></tr>
  74.  
  75. </table>
  76.  
  77. <?
  78. }
  79. ?>
  80. </td>
  81. </tr>
  82.  
  83. </table>

Report this snippet  

You need to login to post a comment.