_objectManager = ObjectManager::getInstance(); $this->_storeManager = $_storeManager; parent::__construct($context, $data); } public function getRSSData() { $rssUrl = $this->getData("url"); $xml = simplexml_load_file($rssUrl); // data type of $xml is Object $dataResponse = array(); foreach ($xml->channel->item as $item) { $description = strip_tags($item->description, ['a']); $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->loadHTML($item->description); $xpath = new DOMXPath($doc); $imgs = $xpath->query("//img"); if (count($imgs) != 0) { $imageURL = $imgs[0]->getAttribute("src"); } else { $imageURL = null; } $obj = array( "image_url" => $imageURL, "title" => $item->title, "link" => $item->link, "description" => $description, ); array_push($dataResponse, $obj); } return $dataResponse; } function getAssetUrl($asset) { $assetRepository = $this->_objectManager->get('Magento\Framework\View\Asset\Repository'); return $assetRepository->createAsset($asset)->getUrl(); } }