Back to FeedParser class

Method parse

public \Joomla\CMS\Feed\Feed
parse
()
Method to parse the feed into a JFeed object.
Returns
  • \Joomla\CMS\Feed\Feed
Since
  • 3.1.4
Class: FeedParser
Project: Joomla

Method parse - Source code

/**
 * Method to parse the feed into a JFeed object.
 *
 * @return  Feed
 *
 * @since   3.1.4
 */
public function parse()
{
    $feed = new Feed();
    // Detect the feed version.
    $this->initialise();
    // Let's get this party started...
    do {
        // Expand the element for processing.
        $el = new \SimpleXMLElement($this->stream->readOuterXml());
        // Get the list of namespaces used within this element.
        $ns = $el->getNamespaces(true);
        // Get an array of available namespace objects for the element.
        $namespaces = array();
        foreach ($ns as $prefix => $uri) {
            // Ignore the empty namespace prefix.
            if (empty($prefix)) {
                continue;
            }
            // Get the necessary namespace objects for the element.
            $namespace = $this->fetchNamespace($prefix);
            if ($namespace) {
                $namespaces[] = $namespace;
            }
        }
        // Process the element.
        $this->processElement($feed, $el, $namespaces);
        // Skip over this element's children since it has been processed.
        $this->moveToClosingElement();
    } while ($this->moveToNextElement());
    return $feed;
}