3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Feed\Reader\Extension;
16 abstract class AbstractFeed
26 * Parsed feed data in the shape of a DOMDocument
30 protected $domDocument = null;
33 * The base XPath query used to retrieve feed data
37 protected $xpath = null;
44 protected $xpathPrefix = '';
47 * Set the DOM document
49 * @param DOMDocument $dom
50 * @return AbstractFeed
52 public function setDomDocument(DOMDocument $dom)
54 $this->domDocument = $dom;
63 public function getDomDocument()
65 return $this->domDocument;
69 * Get the Feed's encoding
73 public function getEncoding()
75 $assumed = $this->getDomDocument()->encoding;
83 * @return AbstractFeed
85 public function setType($type)
87 $this->data['type'] = $type;
94 * If null, it will attempt to autodetect the type.
98 public function getType()
100 $type = $this->data['type'];
101 if (null === $type) {
102 $type = Reader\Reader::detectType($this->getDomDocument());
103 $this->setType($type);
109 * Return the feed as an array
113 public function toArray() // untested
119 * Set the XPath query
121 * @param DOMXPath $xpath
122 * @return AbstractEntry
124 public function setXpath(DOMXPath $xpath = null)
126 if (null === $xpath) {
131 $this->xpath = $xpath;
132 $this->registerNamespaces();
137 * Get the DOMXPath object
141 public function getXpath()
143 if (null === $this->xpath) {
144 $this->setXpath(new DOMXPath($this->getDomDocument()));
151 * Get the XPath prefix
155 public function getXpathPrefix()
157 return $this->xpathPrefix;
161 * Set the XPath prefix
163 * @param string $prefix
166 public function setXpathPrefix($prefix)
168 $this->xpathPrefix = $prefix;
172 * Register the default namespaces for the current feed format
174 abstract protected function registerNamespaces();