How to Make an Auto Update XML Playlist

XML playlists list all of your songs in a structured file, so you can transfer the playlist to another computer or distribute it to friends and family. To create an auto-update XML playlist, you use the PHP language to create the file and create a link to the file on your home page, so users can view a list of your preferred songs.

Instructions

    • 1

      Right-click the PHP file you want to use and click "Open With." Click your preferred PHP editor.

    • 2

      Create the XML playlist file. The following code creates the file you use to update the playlist:

      $xml = new DOMDocument();
      $root = $xmlDoc->appendChild(
      $xml ->createElement("songs"));

      The first root element is also created in the last line of code. The "songs" root node tells XML importers that the data contained in the file is a list of songs.

    • 3

      Create the list of songs. For most playlists, you want to store the song name, the artist and the album. The following code creates nodes for these three pieces of information:

      $song= $root->appendChild();
      $xml->createElement("songname"));
      $artist->appendChild();
      $xml->createAttribute("artist"))->appendChild();
      $xml->createTextNode($artist->author));
      $album->appendChild()
      $xml->createAttribute("album"))->appendChild();
      $xml->createTextNode($album->album));

    • 4

      Save the changes to the file. After you create each song entry in the XML file, you save it to complete the changes. The following code saves the changes:
      $xml->saveXML();

Related Searches:

References

Comments

Related Ads

Featured