summaryrefslogtreecommitdiffstats
path: root/opmlparser.php
blob: 4918b87b1107530b199cb1b11b5c4aeab54fe48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?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 {

	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(){
		
	}
	
	//TODO: implement an iterator to get data in a fancier way
	public function getData() {
		return $this->data;
	}
	
	public function getTitle() {
		return $this->title;
	}
	
	public function getError() {
		return $this->error;
	}
}