本文整理汇总了PHP中SimpleXmlElement::getNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXmlElement::getNamespaces方法的具体用法?PHP SimpleXmlElement::getNamespaces怎么用?PHP SimpleXmlElement::getNamespaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXmlElement
的用法示例。
在下文中一共展示了SimpleXmlElement::getNamespaces方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public function parse()
{
$sXML = new \SimpleXmlElement($this->xml);
$ns = $sXML->getNamespaces(true);
foreach ((array) $sXML->channel as $k => $v) {
if ($k == 'item') {
continue;
}
if (!is_string($v) && !is_array($v)) {
$v = (array) $v;
}
$this->meta[$k] = $v;
}
foreach ($sXML->channel->item as $item) {
$i = (array) $item;
foreach ($ns as $space => $val) {
$children = $item->children($val);
if ($children) {
foreach ($children as $c => $a) {
$i[$c] = (string) $a;
}
}
}
$this->items[] = $i;
}
}
示例2: get
public function get($count = -1, $rating = null, $filter = null)
{
if ($count == 0 || !is_numeric($count)) {
$count = -1;
}
$url = sprintf(self::BACKEND_URL, $this->username) . ($filter == -1 ? '+in%3Ascraps' : '') . ($filter > 0 ? '%2F' . $filter : '');
$this->data = $this->request($url);
$xml = new SimpleXmlElement($this->data);
$ns = $xml->getNamespaces(true);
$items = null;
foreach ($xml->channel->item as $item) {
$media = $item->children($ns['media']);
if (!(empty($this->rating) || $this->rating == 'all') && $media->rating != $this->rating) {
continue;
}
if ($media->text) {
continue;
}
if ($media->text) {
continue;
}
if ($media->text) {
continue;
}
$items .= sprintf('<li><a href="%1$s" title="%2$s - %3$s"><img src="%4$s" alt="%2$s - %3$s"/></a></li>', $item->link, $media->title, $media->copyright, $media->content->attributes()->url);
--$count;
if ($count > -1 && $count == 0) {
break;
}
}
return sprintf('<ul class="da-widgets gallery">%s</ul>', $items);
}
示例3: get
public function get($count = -1)
{
$xml = new SimpleXmlElement($this->data);
$ns = $xml->getNamespaces(true);
$items = null;
foreach ($xml->channel->item as $item) {
$items .= sprintf('<dt><a href="%2$s">%1$s</a></dt>' . '<dd>' . '<p>%3$s</p>' . '</dd>', $item->title, $item->link, $item->description);
--$count;
if ($count > -1 && $count == 0) {
break;
}
}
return sprintf('<dl>%s</dl>', $items);
}
示例4: get
public function get($count = -1)
{
$xml = new SimpleXmlElement($this->data);
$ns = $xml->getNamespaces(true);
$items = null;
foreach ($xml->channel->item as $item) {
$media = $item->children($ns['media']);
if (!(is_null($this->rating) || $this->rating == 'all') && $media->rating != $this->rating) {
continue;
}
$items .= sprintf('<li><a href="%1$s" title="%2$s - %3$s"><img src="%4$s" alt="%2$s - %3$s"/></a></li>', $item->link, $media->title, $media->copyright, $media->content->attributes()->url);
--$count;
if ($count > -1 && $count == 0) {
break;
}
}
return sprintf('<ul class="da-widgets favourite">%s</ul>', $items);
}
示例5: get
public function get($count = -1, $format = 1)
{
if ($count == 0 || !is_numeric($count)) {
$count = -1;
}
$url = sprintf(self::BACKEND_URL, $this->username, $format);
$this->data = $this->request($url);
$xml = new SimpleXmlElement($this->data);
$ns = $xml->getNamespaces(true);
$items = null;
foreach ($xml->channel->item as $item) {
$items .= sprintf('<dt><a href="%2$s">%1$s</a></dt>' . '<dd>' . '<p>%3$s</p>' . '</dd>', $item->title, $item->link, $item->description);
--$count;
if ($count > -1 && $count == 0) {
break;
}
}
return sprintf('<dl class="da-widgets log">%s</dl>', $items);
}