📜 ⬆️ ⬇️

We generate RSS

Everyone knows about RSS and how to read it and even parse , but how to convert an article from a html-code into a valid RSS for a web developer can be problematic. Typical problems include the presence of <,>, & symbols. In addition, the difficulty with the presence of object tags inside the description leads to the fact that you can not make a video object in rss. We try FeedCreator . Hulk, supports all kinds of ATOM, RSS 0.9-RSS 2.0, OPML, MBOX. You need to manually change the encoding to UTF8, the object wants to immediately create an xml file. Well, this is basically reasonable, one-hour caching is not critical for a blog, for news sites it should be reduced to a couple of minutes. $rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = "Artjom Kurapov";
$rss->description = "Personal Blog";
$rss->link = "http://kurapov.name/";
The validator still swears at flash (hence the object is not supported). Also, do not like relative paths. Of course you can change the WYSIWYG so that it immediately generates absolute paths, but in case you have to change the domain, you will have to work a lot with the base. Therefore, we generate them with RSS.
$recEntry->description=preg_replace("//i",'',$recEntry->description);
$recEntry->description=str_replace("href='/","href='http://kurapov.name/",$recEntry->description);
$recEntry->description=str_replace('href="/','href="http://kurapov.name/',$recEntry->description);
$recEntry->date = date('r',$item->unix_added);
$rss->addItem($recEntry);
echo $rss->saveFeed("RSS2.0", "feed.xml");

And as a result

[Valid RSS]

')

Source: https://habr.com/ru/post/13064/


All Articles