Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> System newsów w RSS, Jak zaimportować newsy z RSS do HTML?
-Fipaj-
post
Post #1





Goście







W sieci istnieje kilka poradników, jak dołączyć RSS do HTML, a ja żadnego z nich nie łapię.
Gotowców na swojej stronie nie toleruję, wszystko musi być "Made by Fipaj" (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Tak więc podajcie mi taki prosty kod który importuje kanał RSS i działa zarówno pod php 3 jak i 5.

Z góry dziękuję!
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Gość_kuziu-
post
Post #2





Goście







Masz tu moją klase
  1. <? 
  2. /* 
  3. * Klasa Xml2array 
  4. * @autor kuziu 
  5. * @date 2003/06/08
  6. *
  7. */ 
  8. class Xml2Array{ 
  9.  
  10. var $elements; 
  11. var $file; 
  12. var $array; 
  13.  
  14. function setFile( $_file ){ 
  15. $this->file = $_file; 
  16. } 
  17. function setElements( $_array ){ 
  18. $this->elements = $_array; 
  19. } 
  20.  
  21. function setArray(){ 
  22. $XML = domxml_open_file( $this->file ); 
  23. $XML->document_element(); 
  24.  
  25.  
  26. foreach ($this->elements as $key => $value){ 
  27. $Array[$value] = $XML->get_elements_by_tagname($value); 
  28. } 
  29. // Insere dados no elementos 
  30. foreach ($Array as $key => $value){ 
  31. foreach ($Array[$key] as $k => $v){ 
  32. //if( $c > 1){ 
  33. $this->array[$k][$v->tagname] = $v->get_content(); 
  34. //} 
  35. } 
  36. }  
  37. } 
  38.  
  39. function getArray(){ 
  40. $this->setArray(); 
  41. return $this->array; 
  42. } 
  43.  
  44. function getArrayFromElement( $element ){ 
  45. } 
  46. }
  47. ?>
Go to the top of the page
+Quote Post
--salvi--
post
Post #3





Goście







Kuziu, to na pewno jest twoja klasa - bo mam wątpliwości: zawsze komentujesz kod po hiszpańsku? :-D


Nie ma to jak odkopać wątek sprzed dwóch lat
Zamykam
~Cienki1980
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 11:28