本文整理汇总了PHP中Zend_Feed_Element::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Feed_Element::__construct方法的具体用法?PHP Zend_Feed_Element::__construct怎么用?PHP Zend_Feed_Element::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Feed_Element
的用法示例。
在下文中一共展示了Zend_Feed_Element::__construct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* The Zend_Feed_EntryAbstract constructor takes the URI of the feed the entry
* is part of, and optionally an XML construct (usually a
* SimpleXMLElement, but it can be an XML string or a DOMNode as
* well) that contains the contents of the entry.
*/
public function __construct($uri = null, $element = null)
{
$this->_uri = $uri;
if (!$element instanceof DOMElement) {
if ($element) {
// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
$doc = new DOMDocument();
$success = @$feedDOMDocument->loadXML($element);
@ini_restore('track_errors');
if (!$success) {
throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
}
$element = $doc->getElementsByTagName($this->_rootElement)->item(0);
if (!$element) {
throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
}
} else {
$doc = new DOMDocument('1.0', 'utf-8');
if ($this->_rootNamespace !== null) {
$element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
} else {
$element = $doc->createElement($this->_rootElement);
}
}
}
parent::__construct($element);
}
示例2: __construct
/**
* Zend_Feed_Entry_Abstract constructor
*
* The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry
* is part of, and optionally an XML construct (usually a
* SimpleXMLElement, but it can be an XML string or a DOMNode as
* well) that contains the contents of the entry.
*
* @param string $uri
* @param SimpleXMLElement|DOMNode|string $element
* @return void
* @throws Zend_Feed_Exception
*/
public function __construct($uri = null, $element = null)
{
if (!$element instanceof DOMElement) {
if ($element) {
// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
$doc = new DOMDocument();
$doc = @Zend_Xml_Security::scan($element, $doc);
@ini_restore('track_errors');
if (!$doc) {
// prevent the class to generate an undefined variable notice (ZF-2590)
if (!isset($php_errormsg)) {
if (function_exists('xdebug_is_enabled')) {
$php_errormsg = '(error message not available, when XDebug is running)';
} else {
$php_errormsg = '(error message not available)';
}
}
/**
* @see Zend_Feed_Exception
*/
throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
}
$element = $doc->getElementsByTagName($this->_rootElement)->item(0);
if (!$element) {
/**
* @see Zend_Feed_Exception
*/
throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
}
} else {
$doc = new DOMDocument('1.0', 'utf-8');
if ($this->_rootNamespace !== null) {
$element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
} else {
$element = $doc->createElement($this->_rootElement);
}
}
}
parent::__construct($element);
}