Zend_Feed_Reader does its best not to stick
you in a narrow confine. If you need to work on a feed outside of
Zend_Feed_Reader, you can extract the base
DOMDocument or DOMElement objects from any class, or even an XML
string containing these. Also provided are methods to extract the current DOMXPath
object (with all core and Extension namespaces registered) and the correct prefix used
in all XPath queries for the current Feed or Entry. The basic methods
to use (on any object) are saveXml(),
getDomDocument(),
getElement(),
getXpath() and
getXpathPrefix(). These will let you break
free of Zend_Feed_Reader and do whatever else
you want.
saveXml()returns an XML string containing only the element representing the current object.getDomDocument()returns the DOMDocument object representing the entire feed (even if called from an Entry object).getElement()returns the DOMElement of the current object (i.e. the Feed or current Entry).getXpath()returns the DOMXPath object for the current feed (even if called from an Entry object) with the namespaces of the current feed type and all loaded Extensions pre-registered.getXpathPrefix()returns the query prefix for the current object (i.e. the Feed or current Entry) which includes the correct XPath query path for that specific Feed or Entry.
Here's an example where a feed might include an RSS Extension not
supported by Zend_Feed_Reader out of the box.
Notably, you could write and register an Extension (covered later)
to do this, but that's not always warranted for a quick check. You must register any
new namespaces on the DOMXPath object before use unless they are
registered by Zend_Feed_Reader or an
Extension beforehand.
<?php
$feed = Zend_Feed_Reader::import('http://www.planet-php.net/rdf/');
$xpathPrefix = $feed->getXpathPrefix();
$xpath = $feed->getXpath();
$xpath->registerNamespace('admin', 'http://webns.net/mvcb/');
$reportErrorsTo = $xpath->evaluate('string('
. $xpathPrefix
. '/admin:errorReportsTo)');
Warning
If you register an already registered namespace with a different
prefix name to that used internally by
Zend_Feed_Reader, it will break the
internal operation of this component.




