PHP code example of moell / rss

1. Go to this page and download the library: Download moell/rss library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moell / rss example snippets



public function setEncode($encode); //默认UTF-8

public function channel(array $channel);

public function item(array $item);

public function items(array $items);

public function build();

public function fastBuild(array $channel, array $item);

public function __toString();

$rss = new \Moell\Rss\Rss();

$channel = [
    'title' => 'title',
    'link'  => 'http://moell.cn',
    'description' => 'description',
    'category' => [
        'value' => 'html',
        'attr' => [
            'domain' => 'http://www.moell.cn'
        ]
    ]
];

$rss->channel($channel);

$items = [];
for($i = 0; $i < 2; $i++) {
    $item = [
        'title' => "title".$i,
        'description' => 'description',
        'source' => [
            'value' => 'moell.cn',
            'attr' => [
                'url' => 'http://www.moell.cn'
            ]
        ]
    ];
    $items[] = $item;
    $rss->item($item);
}

echo $rss;	//Get xml

//Other acquisition methods
$rss->build()->asXML();

$rss->fastBuild($channel, $items)->asXML();

$rss->channel($channel)->items($items)->build()->asXML();