parse() public static method

Parses an XML document and returns an array of data.
public static parse ( string $xml ) : array
$xml string XML document.
return array Data.
コード例 #1
0
ファイル: OEmbed.php プロジェクト: muten84/luigibifulco.it
 /**
  *	Parses the given response depending on its format.
  *
  *	@param string $response Response.
  *	@param string $format Format.
  *	@return array Data.
  */
 protected function _parse($response, $format)
 {
     switch ($format) {
         case Format::json:
             return Json::parse($response);
         case Format::xml:
             return Xml::parse($response);
         default:
             throw new Exception('Unsupported response format.');
     }
 }
コード例 #2
0
ファイル: OEmbed.php プロジェクト: ashliewebb/ashliewebb
 /**
  *	Fetches embed information from the given endpoint.
  *
  *	@param string $endpoint Endpoint to fetch informations from.
  *	@param string $format Response format.
  *	@return Media Embed informations.
  */
 protected function _embedEndpoint($endpoint, $format)
 {
     $response = $this->_Http->get($endpoint);
     switch ($format) {
         case self::json:
             $data = Json::parse($response);
             break;
         case self::xml:
             $data = Xml::parse($response);
             break;
         default:
             throw new Exception('Unsupported response format.');
     }
     return new Media(Hash::reindex($data, ['author_name' => 'authorName', 'author_url' => 'authorUrl', 'provider_name' => 'providerName', 'provider_url' => 'providerUrl', 'cache_age' => 'cacheAge', 'thumbnail_url' => 'thumbnailUrl', 'thumbnail_width' => 'thumbnailWidth', 'thumbnail_height' => 'thumbnailHeight']));
 }
コード例 #3
0
 /**
  *
  */
 public function testParseInvalid()
 {
     $this->setExpectedException('Exception');
     Xml::parse($this->invalid);
 }