diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-30 02:24:38 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-30 02:24:38 -0400 |
commit | a5438863a4e88fb5c9e166e8810f493a1feb2cf0 (patch) | |
tree | 5239bdede220fdd4a74f988fa3493cc86b0f33c7 /opmlparser.php | |
parent | 0812aadc7b1eaf45afd8a56640cc5de84d0e3dd7 (diff) |
parses opml file to get the title
Diffstat (limited to 'opmlparser.php')
-rw-r--r-- | opmlparser.php | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/opmlparser.php b/opmlparser.php index 0407e0f7e..4918b87b1 100644 --- a/opmlparser.php +++ b/opmlparser.php @@ -1,13 +1,36 @@ <?php +/** +* ownCloud - News app +* +* @author Alessandro Cosentino +* Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> +* +* This file is licensed under the Affero General Public License version 3 or later. +* See the COPYING-README file +* +*/ + class OPMLParser { - public $raw; - public $data; + private $raw; + private $body; + private $data; + private $title; + private $error; public function __construct($raw) { $this->raw = $raw; $this->data = array(); + try { + $xml_parser = new SimpleXMLElement($this->raw, LIBXML_NOERROR); + $this->title = (string)$xml_parser->head->title; + $this->body = $xml_parser->body; + } + catch (Exception $e) { + $this->error = $e->getMessage(); + return; + } } public function parse(){ @@ -19,4 +42,11 @@ class OPMLParser { return $this->data; } + public function getTitle() { + return $this->title; + } + + public function getError() { + return $this->error; + } }
\ No newline at end of file |