当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleXMLElement::getNameSpaces方法代码示例

本文整理汇总了PHP中SimpleXMLElement::getNameSpaces方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLElement::getNameSpaces方法的具体用法?PHP SimpleXMLElement::getNameSpaces怎么用?PHP SimpleXMLElement::getNameSpaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLElement的用法示例。


在下文中一共展示了SimpleXMLElement::getNameSpaces方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _loadComments

 private function _loadComments()
 {
     $youtube = new YouTube($this->_developerKey);
     $data = $youtube->getComments($this->_id, $this->_maxResults, $this->_startIndex);
     $xml = new SimpleXMLElement($data);
     //fetch comments
     $this->_comments = array();
     foreach ($xml->entry as $entry) {
         $comment = new YouTubeVideoComment($entry);
         $this->_comments[] = $comment;
     }
     //fetch list data
     $namespaces = $xml->getNameSpaces(true);
     if ($namespaces) {
         $openSearch = $entry->children($namespaces['openSearch']);
     } else {
         return FALSE;
     }
     $this->_totalVideos = (int) $openSearch->totalResults;
     $this->_startIndex = (int) $openSearch->startIndex;
     $this->_maxResults = (int) $openSearch->itemsPerPage;
     if ($this->_comments) {
         return TRUE;
     }
     /* else */
     return FALSE;
 }
开发者ID:wljcom,项目名称:YouTube-1,代码行数:27,代码来源:youtube.video.comments.php

示例2: XtractMessage

 public static function XtractMessage($p_cloudBankException)
 {
     /* This is a work around to get the error message from the exception
     	    coming from the seriously broken SOAPFault implementation of SCA_SDO
     	 */
     $v_exceptionMessage = $p_cloudBankException->getMessage();
     if ($v_xmlOpeningTagPos = strpos($v_exceptionMessage, '<?xml')) {
         $v_soapFaultXML = new SimpleXMLElement(substr($v_exceptionMessage, $v_xmlOpeningTagPos));
         $v_soapFaultXMLNamespaces = $v_soapFaultXML->getNameSpaces();
         $v_message = (string) $v_soapFaultXML->children($v_soapFaultXMLNamespaces['SOAP-ENV'])->Body->Fault->children()->faultstring;
     } else {
         $v_message = $v_exceptionMessage;
     }
     return $v_message;
 }
开发者ID:psagi,项目名称:cloudbank,代码行数:15,代码来源:Book.php

示例3: _loadInfo

 private function _loadInfo()
 {
     $data = $this->_youtube->getUserData($this->_username);
     $xml = new SimpleXMLElement($data);
     $namespaces = $xml->getNameSpaces(true);
     if ($namespaces) {
         $yt = $xml->children($namespaces['yt']);
     } else {
         return FALSE;
     }
     $this->_channelTitle = (string) $xml->title;
     $this->_age = (string) $yt->age;
     $this->_gender = (string) $yt->gender;
     $this->_location = (string) $yt->location;
     $this->_loaded = TRUE;
 }
开发者ID:wljcom,项目名称:YouTube-1,代码行数:16,代码来源:youtube.user.php

示例4: get_itunes_top100_song

function get_itunes_top100_song()
{
    echo "get itunes top 100 song ...";
    $ar = array();
    $html = get_data("https://itunes.apple.com/de/rss/topsongs/limit=100/explicit=true/xml", "ITUNES");
    try {
        $arx = new SimpleXMLElement($html);
    } catch (Exception $e) {
        return "";
    }
    $namespaces = $arx->getNameSpaces(true);
    foreach ($arx->entry as $a) {
        $im = $a->children($namespaces['im']);
        $ar[] = array('title' => (string) $im->name, 'artist' => (string) $im->artist, 'id' => (string) $a->id);
    }
    echo "done\n";
    return $ar;
}
开发者ID:MusicalAPP,项目名称:gfk-api-spotify-itunes,代码行数:18,代码来源:loader.php

示例5: createEntryForItem

 /**
  * Create a entry for given item
  *
  * @param SimpleXMLElement $item
  * @param RDR_Feed $feed
  * @return RDR_Entry | null
  */
 private static function createEntryForItem($item, RDR_Feed $feed)
 {
     $guid = self::xmlValue($item->guid);
     if (!$guid) {
         $guid = self::xmlValue($item->id);
     }
     if (!$guid) {
         $guid = self::xmlValue($item->link);
     }
     $entry = RDR_Entry::get($feed, $guid);
     $now = dt("now");
     $entry->title = null;
     $entry->title = cut(self::xmlValue($item->title), 252, "...");
     $entry->text = null;
     $entry->text = self::xmlValue($item->description);
     if (!$entry->text) {
         $entry->text = self::xmlValue($item->content);
     }
     if (!$entry->text) {
         $entry->text = self::xmlValue($item->summary);
     }
     $entry->datetime = null;
     $entry->datetime = dt(self::xmlValue($item->pubDate));
     if (!$entry->datetime->valid) {
         $entry->datetime = dt(self::xmlValue($item->published));
     }
     if (!$entry->datetime->valid) {
         $entry->datetime = dt(self::xmlValue($item->updated));
     }
     if ($entry->datetime->valid && $entry->datetime->getUnixtime() > $now->getUnixtime()) {
         $entry->datetime = $now;
     }
     $count = count($item->link);
     foreach ($item->link as $link) {
         if ($count > 1) {
             if (self::xmlAttr($link, "type") == "text/html") {
                 $entry->link = self::xmlAttr($link, "href");
             }
         } else {
             $entry->link = self::xmlValue($link);
         }
     }
     if (!$entry->link) {
         $entry->link = self::xmlValue($item->link);
     }
     if (!$entry->link) {
         $entry->link = self::xmlAttr($item->link, "href");
     }
     $entry->image = null;
     $enclosures = $item->xpath("enclosure");
     if ($enclosures) {
         foreach ($enclosures as $encl) {
             if ($entry->image) {
                 break;
             }
             if (self::xmlAttr($encl, "type")) {
                 if (strpos(self::xmlAttr($encl, "type"), "image") !== false) {
                     $entry->image = self::xmlAttr($encl, "url");
                 }
             } elseif (self::xmlAttr($encl, "url")) {
                 if (preg_match("~jpg|jpeg|gif|png~i", self::xmlAttr($encl, "url"))) {
                     $entry->image = self::xmlAttr($encl, "url");
                 }
             }
         }
     }
     $namespaces = $item->getNameSpaces(true);
     if ($namespaces) {
         foreach ($namespaces as $ns) {
             $tmp = $item->children($ns);
             foreach ($tmp as $key => $value) {
                 if (!$entry->datetime->valid && strpos($key, "date") !== false) {
                     $entry->datetime = dt(self::xmlValue($value));
                 }
                 if (!$entry->title && strpos($key, "title") !== false) {
                     $entry->title = cut(self::xmlValue($value), 252, "...");
                 }
                 if (strpos($key, "description") !== false || strpos($key, "content") !== false || strpos($key, "encoded") !== false) {
                     $text = self::xmlValue($value);
                     if ($text && (!$entry->text || mb_strlen($text) > $entry->text)) {
                         $entry->text = $text;
                     }
                     if (!$entry->image) {
                         $attr = $value->attributes();
                         $url = isset($attr->url) ? self::xmlValue($attr->url) : null;
                         $type = isset($attr->type) ? self::xmlValue($attr->type) : null;
                         if ($url && (preg_match("~\\.(jpg|jpeg|png|gif)~i", $url) || preg_match("~image\\/~i", $type))) {
                             $entry->image = $url;
                         }
                     }
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:nonconforme,项目名称:nreeda,代码行数:101,代码来源:Import.class.php

示例6: parseVideoRow

		/**
		* This function takes in a SimpleXML Object, sets the template variables and parses the template based on it.
		* The expected object is a 'entry' node from an ATOM feed from YouTube.
		*
		* @param SimpleXMLElement $video An 'entry' node from an ATOM feed.
		*/
		private function parseVideoRow($video)
		{
			$rating      = '';
			$ratingStars = '';
			$viewCount   = '0';

			// get the thumbnail image
			$namespaces = $video->getNameSpaces(true);

			// get the media namespace
			$media = $video->children($namespaces['media']);

			// get the gd namespace, which contains information about the video ratings
			$ratings = $video->children($namespaces['gd']);

			// get the yt namespace, which contains information abouts the video statistics and video ID
			$stats = $video->children($namespaces['yt']);

			$thumbnail = $media->group->thumbnail->attributes();
			$length    = $media->group->content->attributes();
			$videoInfo = $media->group->children($namespaces['yt']);
			$duration  = $videoInfo->duration->attributes();

			// finding the video ID can be tricky
			$videoId = trim((string)@$videoInfo->videoid);

			if(empty($videoId)) {
				$videoId = @$video->id;
				if(!empty($videoId)) {
					$videoId = str_replace('http://gdata.youtube.com/feeds/api/videos/', '', $videoId);
				}
			}

			// the duration of the vieo is given in seconds, we want to format it into minutes
			$length = date('G:i:s', (int)$duration['seconds']);

			// if it's less than an hour, don't show zero for the hours
			if(substr($length,0, 2) == '0:') {
				$length = substr($length, 2);
			}

			// not all videos come with statistics, so if there is none, just ignore this code block
			if(isset($stats->statistics)) {
				$statsInfo = $stats->statistics->attributes();
				$viewCount = $statsInfo['viewCount'];
			}

			// not all videos come with rating information :(
			if(isset($ratings->rating)) {
				$rating = $ratings->rating->attributes();
				$averageRating = (float)$rating['average'];
				$ratingNumber = round($averageRating, 0);
				$ratingNumber = min($ratingNumber, 5);
				$ratingNumber = max($ratingNumber, 1);

				for($i=1; $i<=$ratingNumber; $i++) {
					$ratingStars .= $this->template->render('Snippets/RatingOn.html');
				}

				for($i=1; $i<=(5-$ratingNumber); $i++) {
					$ratingStars .= $this->template->render('Snippets/RatingOff.html');
				}
			}

			// set up the video summary, we need to make sure it's a string and that it's not too long
			$summary = (string)$media->group->description;
			if(strlen($summary) > 85) {
				$summary = substr($summary, 0, 85) . "...";
			}

			// set up the video title, we need to make sure it's a string and that it's not too long
			$title = (string)$video->title;
			if(strlen($title) > 25) {
				$title = substr($title, 0, 23) . "...";
			}

			$GLOBALS['videoLength']    = $length;
			$GLOBALS['videoRating']    = $ratingStars;
			$GLOBALS['videoId']        = $videoId;
			$GLOBALS['videoViews']     = number_format($viewCount);
			$GLOBALS['videoTitle']     = isc_html_escape($title);
			$GLOBALS['videoTitleFull'] = isc_html_escape((string)$video->title);
			$GLOBALS['videoImage']     = (string)$thumbnail['url'];
			$GLOBALS['videoSummary']   = isc_html_escape($summary);
			$GLOBALS['videoSummaryFull'] = isc_html_escape((string)$media->group->description);

			$html = $this->template->render('Snippets/YouTubeVideoRow.html');

			// IE doesn't like new lines in lists at all, it adds weird spacing between list items.
			$html = str_replace(array("\r", "\n"), '', $html);

			return $html;
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:99,代码来源:class.remote.products.php

示例7: _parseAtom

 private function _parseAtom($data)
 {
     $xml = new SimpleXMLElement($data);
     //fetch videos
     $this->_videos = array();
     foreach ($xml->entry as $entry) {
         $video = new YouTubeVideo($entry, $this->_developerKey);
         $this->_videos[] = $video;
     }
     //fetch list data
     $namespaces = $xml->getNameSpaces(true);
     if ($namespaces) {
         $openSearch = $xml->children($namespaces['openSearch']);
     } else {
         return FALSE;
     }
     $this->_totalVideos = (int) $openSearch->totalResults;
     $this->_startIndex = (int) $openSearch->startIndex;
     $this->_maxResults = (int) $openSearch->itemsPerPage;
     if ($this->_videos) {
         return TRUE;
     }
     /* else */
     return FALSE;
 }
开发者ID:wljcom,项目名称:YouTube-1,代码行数:25,代码来源:youtube.videolist.php


注:本文中的SimpleXMLElement::getNameSpaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。