PHP code example of sitask / xml-feed-parser

1. Go to this page and download the library: Download sitask/xml-feed-parser 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/ */

    

sitask / xml-feed-parser example snippets




use Sita\XmlFeed\FeedParser;

$parser = new FeedParser();

// XML si stiahnete ako chcete - curl, Guzzle, file_get_contents...
$xml = file_get_contents('https://example.sita.sk/feed.xml?token=...');

$articles = $parser->parse($xml);

foreach ($articles as $article) {
    echo $article['title'], "\n";
    echo $article['thumbnail']['url'], "\n";
}

// Chyby sa nehádžu ako výnimky - jeden pokazený kanál nemá zhodiť celý beh.
foreach ($parser->get_errors() as $error) {
    error_log('SITA feed: ' . $error);
}

[
    '_w_id'          => '12345',              // ID článku v SITA
    'u_id'           => 'abc-123',            // UnikatneID
    'date_published' => '2026-08-19',
    'time_publish'   => '10:30:00',
    'date_modified'  => '2026-08-19',
    'time_modified'  => '11:00:00',
    'title'          => 'Nadpis',
    'perex'          => 'Perex',
    'content'        => '<p>Telo článku</p>', // HTML prefiltrované
    'section'        => ['category' => 'Ekonomika', 'sub_category' => 'Financie'],
    'locations'      => ['Bratislava'],
    'thumbnail'      => [
        'url'     => 'https://img.sita.sk/foto.jpg',
        'size'    => '2048',
        'width'   => '800',
        'height'  => '600',
        'caption' => 'Popis obrázka',  // null, ak kanál prvok neposiela
        'source'  => 'SITA/Ján Novák', // null, ak kanál prvok neposiela
    ],
]

$parser = new FeedParser('<a><strong><em>');
bash
php tests/parser-smoke-test.php