Comments (5)
@podcasthosting
Please try the following example: (based on "Writer: Getting Started")
// Create feed
$feed = new Laminas\Feed\Writer\Feed;
$feed->setTitle("Paddy's Blog");
$feed->setDescription("Paddy's Blog");
$feed->setLink('http://www.example.com');
// Create entry
$entry = $feed->createEntry();
$entry->setTitle('All Your Base Are Belong To Us');
$entry->setLink('http://www.example.com/all-your-base-are-belong-to-us');
$entry->addAuthor([
'name' => 'Paddy',
'email' => '[email protected]',
'uri' => 'http://www.example.com',
]);
$entry->setDateModified(time());
$entry->setDateCreated(time());
$entry->setDescription('Exposing the difficulty of porting games to English.');
$entry->setContent(
'I am not writing the article. The example is long enough as is ;).'
);
$feed->addEntry($entry);
// Render feed (creates DOMDocument object)
$writer = new Laminas\Feed\Writer\Renderer\Feed\Rss($feed);
$writer->render();
// Add processing instruction
$writer->getElement()->parentNode->insertBefore(
$writer->getDomDocument()->createProcessingInstruction(
'xml-stylesheet',
'title="Demo" type="text/xsl" href="https://files.orf.at/podcast/oe1/podcast.xsl"'
),
$writer->getElement()
);
// Ouput XML
echo $writer->saveXml();
Ouput:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet title="Demo" type="text/xsl" href="https://files.orf.at/podcast/oe1/podcast.xsl"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>Paddy's Blog</title>
<description>Paddy's Blog</description>
<generator>Laminas_Feed_Writer 2 (https://getlaminas.org)</generator>
<link>http://www.example.com</link>
<item>
<title>All Your Base Are Belong To Us</title>
<description><![CDATA[Exposing the difficulty of porting games to English.]]></description>
<pubDate>Thu, 24 Sep 2020 06:43:50 +0000</pubDate>
<link>http://www.example.com/all-your-base-are-belong-to-us</link>
<guid>http://www.example.com/all-your-base-are-belong-to-us</guid>
<author>[email protected] (Paddy)</author>
<dc:creator>Paddy</dc:creator>
<content:encoded><![CDATA[I am not writing the article. The example is long enough as is ;).]]></content:encoded>
<slash:comments>0</slash:comments>
</item>
</channel>
</rss>
from laminas-feed.
An XSLT transformation is usually best applied to the XML feed directly, and not through a third party component or language. XSLT is Turing complete, and also a very good FP language, so I'd suggest digging that way first (by piping the XML directly through CLI XML tools).
Originally posted by @Ocramius at zendframework/zend-feed#107 (comment)
from laminas-feed.
@Ocramius If I understand you correctly than what you are suggesting is not what I want to achieve. I want to make a RSS feed look good in the browser. It should be the feed generated through zend-feed itself without piping it through any extra tools.
Originally posted by @podcasthosting at zendframework/zend-feed#107 (comment)
from laminas-feed.
I'd rather say that you take the RSS feed (input or output) and pass it to XSLT directly: XSLT is good and mature, use it π
Originally posted by @Ocramius at zendframework/zend-feed#107 (comment)
from laminas-feed.
taken from an ORF podcast feed.
Example: https://files.orf.at/podcast/oe1/oe1_imoe1journalzugast.xml
from laminas-feed.
Related Issues (20)
- Getting "failed to open stream: No such file or directory in /autoload.php on line 5" when loading package HOT 5
- Atom Feed canβt read Entry content if type is application/xml
- Replace usage of deprecated libxml_disable_entity_loader() HOT 2
- Psalm integration HOT 2
- PHP 8.0 support HOT 1
- PHPDoc return types incorrect/outdated HOT 1
- Method getDateModified of RSS reader doesn't iterate over different formats HOT 2
- PubSubHubbub/Publisher not sending requests to hubs
- Itunes categories with same main category are overwritten HOT 9
- Laminas-http mishandles multiple headers causing failure HOT 2
- feedLink() is broken, returns invalid data if not found HOT 3
- CRLF in vendor/laminas/laminas-feed/CHANGELOG.md HOT 5
- Add code example for feed-writer to add a media object via the enclosure element
- Dependency Dashboard
- Error 500 when rendering a feed with some set*() methods HOT 2
- Add support for laminas/laminas-servicemanager 4.0 so this library can be used on PHP 8.2 + psr/container 2.0. HOT 4
- DateTime::createFromFormat(): Argument #2 ($datetime) must be of type string, bool given HOT 1
- Laminas\Feed\Reader\ExtensionManagerInterface is said to be deprecated, but it still looks like to be required HOT 5
- DOMDocument::loadXML(): CData section too big found HOT 4
- Add PHP 8.4 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laminas-feed.