Exemple #1
0
 /**
  * Get XML representation of track.
  *
  * @return string
  */
 public function asXML()
 {
     $xml = new MBSimpleXMLElement('<track></track>');
     $xml->addAttribute("href", $this->getURI());
     $xml->addCData("name", $this->getTitle());
     // Add artists
     if ($this->artist != null) {
         if (is_array($this->artist)) {
             foreach ($this->artist as $artist) {
                 $xml->addXMLElement(new MBSimpleXMLElement($artist->asXML()));
             }
         } else {
             $xml->addXMLElement(new MBSimpleXMLElement($this->artist->asXML()));
         }
     }
     if ($this->album != null) {
         $xml->addXMLElement(new MBSimpleXMLElement($this->album->asXML()));
     }
     $xml->addChild("length", $this->length);
     $xml->addChild("popularity", $this->popularity);
     $xml->addChild("track-number", $this->trackNr);
     $xml->addChild("disc-number", $this->discNr);
     return $xml->asXML();
 }
 /**
  * Get XML representation of artist.
  *
  * @return string
  */
 public function asXML()
 {
     $xml = new MBSimpleXMLElement('<artist></artist>');
     $xml->addAttribute("href", $this->getURI());
     $xml->addCData("name", $this->getName());
     $albumXML = $xml->addChild("albums");
     foreach ($this->albums as $album) {
         $albumXML->addXMLElement(new MBSimpleXMLElement($album->asXML()));
     }
     $xml->addChild("popularity", $this->popularity);
     return $xml->asXML();
 }
 /**
  * Get XML representation of album.
  *
  * @return string
  */
 public function asXML()
 {
     $xml = new MBSimpleXMLElement('<album></album>');
     $xml->addAttribute("href", $this->getURI());
     $xml->addCData("name", $this->getName());
     $xml->addXMLElement(new MBSimpleXMLElement($this->artist->asXML()));
     $tracksElement = $xml->addChild("tracks");
     foreach ($this->tracks as $track) {
         $tracksElement->addXMLElement(new MBSimpleXMLElement($track->asXML()));
     }
     $xml->addChild("popularity", $this->popularity);
     $xml->addChild("released", $this->release);
     return $xml->asXML();
 }