saqueib / qrss

PHP API class for parsing RSS feed and returning JSON http://www.qcode.in/build-complete-rss-feed-reader-app-php-rss-json-api/
MIT License
20 stars 9 forks source link

Option to get data in plain text added #4

Closed vtisnado closed 7 years ago

vtisnado commented 7 years ago

Hi @saqueib I found that sometimes is really helpful to get text plain data in case you want to extract just one value of the feed. I'm using it this way:

class MyQrss extends QRss {
    protected function parse($xml)
    {
        if( is_object($xml) ) {
            $link = (string) $xml->__VALUE__->Link;
        }
        $this->json_response([ "{$this->error_msg_key}" => 'Unable to Parse xml format.'], 500);
        return false;
    }
}

(new MyQrss( [RSS_URL] ))->fresh()->novalidate()->text();