<?php
use PicoFeed\Serialization\SubscriptionListParser;
// Parse $opmlData and returns a SubscriptionList object
$subscriptionList = SubscriptionListParser::create($opmlData)->parse();$opmlDatais a string that contains the OPML file contents- The method
parse()returns aSubscriptionListobject
If the XML file is invalid, a exception PicoFeed\Parser\MalformedXmlException is raised.
<?php
use PicoFeed\Serialization\SubscriptionListBuilder;
// Serialize the object $subscriptionList to OPML
$opmlBuilder = new SubscriptionListBuilder($subscriptionList);
echo $opmlBuilder->build();- The constructor of the class
SubscriptionListBuildertakes aSubscriptionListobject as argument - The method
build()serialize the object to OPML as a string - You can also save the content to a file by using
$opmlBuilder->build('/path/to/feeds.opml');
The SubscriptionList object define a list of feeds that can be exported or imported by PicoFeed.
Here is the list of getters and setters:
setTitle($title)/getTitle()addSubscription(Subscription $subscription)
The attribute SubscriptionList::subscriptions contains the list of feeds.
The Subscription object represents a single feed.
Here is the list of getters and setters:
setTitle($title)/getTitle()setFeedUrl($feedUrl)/getFeedUrl()setSiteUrl($siteUrl)/getSiteUrl()setCategory($category)/getCategory()setDescription($description)/getDescription()setType($type)/getType()
The title and the feed url are mandatory when you generate a new OPML feed.