Code Monkey home page Code Monkey logo

Comments (5)

froschdesign avatar froschdesign commented on September 26, 2024 1

@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.

weierophinney avatar weierophinney commented on September 26, 2024

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.

weierophinney avatar weierophinney commented on September 26, 2024

@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.

weierophinney avatar weierophinney commented on September 26, 2024

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.

froschdesign avatar froschdesign commented on September 26, 2024

taken from an ORF podcast feed.

Example: https://files.orf.at/podcast/oe1/oe1_imoe1journalzugast.xml

from laminas-feed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.