[script] Read Feed

Only PHP & MySQL.

Moderator: DaD

[script] Read Feed

Postby DaD on Mon Jul 28, 2008 9:03 pm

Questa classe è compatibile solo con php5 è superiori ... (aggiungerei anche pd -.-)

Code: Select all
<?php
      class readrss {
           public $dom;
           public $items = array();

           public function __construct($url, $itemTagName){
                 $dom = new DOMDocument();
                 $feed = file_get_contents($url);
                 $readResult = @$dom->loadXML($feed);
                 if(!$readResult)
                   throw new Exception("Error XML!");


                 $this->dom = $dom;
                 $xpath = new DOMXPath($dom);
                 $xpathQuery = $xpath->query("//$itemTagName");

                 $count = 0;
                 foreach($xpathQuery as $item){
                        $this->items[$count] = new readitem($item);
                        $count++;
                 }

          }
     }

     class readitem {
          public $itemTags = array();

          public function __construct($itemNode){
                foreach($itemNode->childNodes as $node)
                       $this->itemTags[$node->tagName] = $node->nodeValue;
          }

          public function __get($node){
                return $this->itemTags[$node];
          }

          public function __set($node, $value){
                $this->itemTags[$node] = $value;
          }

   }
?>
Image
Le tre grandi virtù di un programmatore: pigrizia, impazienza e arroganza. (Larry Wall)
Get Slack! | User Linux's ID | Blog
User avatar
DaD
Php Guru
 
Posts: 322
Joined: Sat Nov 25, 2006 5:09 pm

[script] Read Feed

Sponsor

Sponsor


Re: [script] Read Feed

Postby k8 on Tue Jul 29, 2008 1:38 pm

Big-Bug cerca collaboratori.
Scrivete senza abbreviazioni e senza k, grazie.
k8
Admin
 
Posts: 2127
Joined: Tue Jun 06, 2006 4:00 pm

Re: [script] Read Feed

Postby DaD on Tue Jul 29, 2008 1:59 pm

keit ma solo tè puoi uppare i source nel portale? Nella versione vecchia anche i mod abilitati potevan o no? :0
Image
Le tre grandi virtù di un programmatore: pigrizia, impazienza e arroganza. (Larry Wall)
Get Slack! | User Linux's ID | Blog
User avatar
DaD
Php Guru
 
Posts: 322
Joined: Sat Nov 25, 2006 5:09 pm

Re: [script] Read Feed

Postby k8 on Tue Jul 29, 2008 2:13 pm

DaD wrote:keit ma solo tè puoi uppare i source nel portale? Nella versione vecchia anche i mod abilitati potevan o no? :0


:arrow: st-ff-zone/nuovi-moderatori-t1813.html
ti ho aggiunto
Big-Bug cerca collaboratori.
Scrivete senza abbreviazioni e senza k, grazie.
k8
Admin
 
Posts: 2127
Joined: Tue Jun 06, 2006 4:00 pm

Re: [script] Read Feed

Postby DaD on Tue Jul 29, 2008 2:42 pm

Occhei :D
Image
Le tre grandi virtù di un programmatore: pigrizia, impazienza e arroganza. (Larry Wall)
Get Slack! | User Linux's ID | Blog
User avatar
DaD
Php Guru
 
Posts: 322
Joined: Sat Nov 25, 2006 5:09 pm


Return to PHP & MySQL

Who is online

Users browsing this forum: No registered users and 1 guest