當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tag::fromSimpleXMLElement方法代碼示例

本文整理匯總了PHP中Tag::fromSimpleXMLElement方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tag::fromSimpleXMLElement方法的具體用法?PHP Tag::fromSimpleXMLElement怎麽用?PHP Tag::fromSimpleXMLElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tag的用法示例。


在下文中一共展示了Tag::fromSimpleXMLElement方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTopTags

 /** Get the top tags used by this user.
  *
  * @param	string	$user	The user name to fetch top tags for. (Required)
  * @param	integer	$limit	Limit the number of tags returned. (Optional)
  * @return	array			An array of Tag objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopTags($user, $limit = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('user.getTopTags', array('user' => $user, 'limit' => $limit));
     $tags = array();
     foreach ($xml->children() as $tag) {
         $tags[] = Tag::fromSimpleXMLElement($tag);
     }
     return $tags;
 }
開發者ID:niczak,項目名稱:php-last.fm-api,代碼行數:19,代碼來源:User.php

示例2: fromSimpleXMLElement

 /** Create a Track object from a SimpleXMLElement.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement.
  * @return	Track						A Track object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $topTags = array();
     if (count($xml->image) > 1) {
         foreach ($xml->image as $image) {
             $images[Util::toImageType($image['size'])] = Util::toString($image);
         }
     } else {
         $images[Media::IMAGE_UNKNOWN] = Util::toString($xml->image);
     }
     if ($xml->toptags) {
         foreach ($xml->toptags->children() as $tag) {
             $topTags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->artist) {
         if ($xml->artist->name && $xml->artist->mbid && $xml->artist->url) {
             $artist = new Artist(Util::toString($xml->artist->name), Util::toString($xml->artist->mbid), Util::toString($xml->artist->url), array(), 0, 0, 0, array(), array(), '', 0.0);
         } else {
             $artist = Util::toString($xml->artist);
         }
     } else {
         if ($xml->creator) {
             $artist = Util::toString($xml->creator);
         } else {
             $artist = '';
         }
     }
     if ($xml->name) {
         $name = Util::toString($xml->name);
     } else {
         if ($xml->title) {
             $name = Util::toString($xml->title);
         } else {
             $name = '';
         }
     }
     // TODO: <extension application="http://www.last.fm">
     return new Track($artist, Util::toString($xml->album), $name, Util::toString($xml->mbid), Util::toString($xml->url), $images, Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), Util::toInteger($xml->duration), $topTags, Util::toInteger($xml->id), Util::toString($xml->location), Util::toBoolean($xml->streamable), Util::toBoolean($xml->streamable['fulltrack']), $xml->wiki, Util::toTimestamp($xml->date));
 }
開發者ID:niczak,項目名稱:php-last.fm-api,代碼行數:50,代碼來源:Track.php

示例3: fromSimpleXMLElement

 /** Create an Artist object from a SimpleXMLElement object.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement object.
  * @return	Artist						An Artist object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $tags = array();
     $similar = array();
     /* NOTE: image, image_small... this sucks! */
     if ($xml->image) {
         if (count($xml->image) > 1) {
             foreach ($xml->image as $image) {
                 $images[Util::toImageType($image['size'])] = Util::toString($image);
             }
         } else {
             $images[Media::IMAGE_LARGE] = Util::toString($image);
         }
     }
     if ($xml->image_small) {
         $images[Media::IMAGE_SMALL] = Util::toString($xml->image_small);
     }
     if ($xml->tags) {
         foreach ($xml->tags->children() as $tag) {
             $tags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->similar) {
         foreach ($xml->similar->children() as $artist) {
             $similar[] = Artist::fromSimpleXMLElement($artist);
         }
     }
     return new Artist(Util::toString($xml->name), Util::toString($xml->mbid), Util::toString($xml->url), $images, Util::toBoolean($xml->streamable), Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), $tags, $similar, $xml->bio ? Util::toString($xml->bio->summary) : "", Util::toFloat($xml->match));
 }
開發者ID:niczak,項目名稱:php-last.fm-api,代碼行數:39,代碼來源:Artist.php

示例4: search

 /** Search for a tag by name. Returns matches sorted by relevance.
  *
  * @param	string	$tag	The tag name in question. (Required)
  * @param	integer	$limit	Limit the number of tags returned at one time. Default (maximum) is 30. (Optional)
  * @param	integer	$page	Scan into the results by specifying a page number. Defaults to first page. (Optional)
  * @return	array			An array of Tag objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function search($tag, $limit = null, $page = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('tag.search', array('tag' => $tag, 'limit' => $limit, 'page' => $page));
     $tags = array();
     foreach ($xml->tagmatches->children() as $tag) {
         $tags[] = Tag::fromSimpleXMLElement($tag);
     }
     return $tags;
 }
開發者ID:niczak,項目名稱:php-last.fm-api,代碼行數:20,代碼來源:Tag.php

示例5: fromSimpleXMLElement

 /** Create an Album object from a SimpleXMLElement object.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement object.
  * @return	Album						An Album object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $topTags = array();
     /* TODO: tagcount | library.getAlbums */
     if ($xml->mbid) {
         $mbid = Util::toString($xml->mbid);
     } else {
         if ($xml['mbid']) {
             $mbid = Util::toString($xml['mbid']);
         } else {
             $mbid = '';
         }
     }
     foreach ($xml->image as $image) {
         $images[Util::toImageType($image['size'])] = Util::toString($image);
     }
     if ($xml->toptags) {
         foreach ($xml->toptags->children() as $tag) {
             $topTags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->artist->name && $xml->artist->mbid && $xml->artist->url) {
         $artist = new Artist(Util::toString($xml->artist->name), Util::toString($xml->artist->mbid), Util::toString($xml->artist->url), array(), 0, 0, 0, array(), array(), '', 0.0);
     } else {
         if ($xml->artist && $xml->artist['mbid']) {
             $artist = new Artist(Util::toString($xml->artist), Util::toString($xml->artist['mbid']), '', array(), 0, 0, 0, array(), array(), '', 0.0);
         } else {
             $artist = Util::toString($xml->artist);
         }
     }
     return new Album($artist, Util::toString($xml->name), Util::toInteger($xml->id), $mbid, Util::toString($xml->url), $images, Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), Util::toTimestamp($xml->releasedate), $topTags);
 }
開發者ID:niczak,項目名稱:php-last.fm-api,代碼行數:42,代碼來源:Album.php


注:本文中的Tag::fromSimpleXMLElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。