Last active
March 2, 2017 04:09
-
-
Save GoodChancer/e75b42561604456240f8ea7db062f77c to your computer and use it in GitHub Desktop.
Playlist Static
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* create a dom document with encoding utf8 */ | |
//create a new xmlwriter object | |
$xml = new XMLWriter(); | |
//using memory for string output | |
$xml->openMemory(); | |
//set the indentation to true (if false all the xml will be written on one line) | |
$xml->setIndent(true); | |
$xml->setIndentString("\t"); | |
//create the document tag, you can specify the version and encoding here | |
$xml->startDocument('1.0', 'UTF-8'); | |
$xml->writeDTD("plist","-//Apple Computer//DTD PLIST 1.0//EN","http://www.apple.com/DTDs/PropertyList-1.0.dtd"); | |
//Create an element | |
$xml->startElement("plist"); | |
$xml->writeAttribute('version','1.0'); | |
$xml->writeElement("dict"); | |
$xml->writeElement("key", "Major Version"); | |
$xml->writeElement("integer", "1"); | |
$xml->writeElement("key", "Minor Version"); | |
$xml->writeElement("integer", "1"); | |
$xml->writeElement("key", "Date"); | |
$xml->writeElement("date", "2017-02-17T22:37:56Z"); | |
$xml->writeElement("key", "Application Version"); | |
$xml->writeElement("string", "12.5.5.5"); | |
$xml->writeElement("key", "Features"); | |
$xml->writeElement("integer", "5"); | |
$xml->writeElement("key", "Tracks"); | |
$xml->startElement("dict"); | |
//loop me | |
$xml->writeElement("key", "1"); | |
$xml->startElement("dict"); | |
$xml->writeElement("key", "Track ID"); | |
$xml->writeElement("integer", "1"); | |
$xml->writeElement("key", "Name"); | |
$xml->writeElement("string", "King and Cross"); | |
$xml->writeElement("key", "Artist"); | |
$xml->writeElement("string", "Ásgeir"); | |
$xml->writeElement("key", "Album"); | |
$xml->writeElement("string", "In the Silence (Deluxe Edition)"); | |
$xml->writeElement("key", "Track Type"); | |
$xml->writeElement("string", "Remote"); | |
$xml->writeElement("key", "Apple Music"); | |
$xml->writeElement("true"); | |
$xml->endElement(); | |
$xml->endElement(); | |
$xml->writeElement("key", "Playlists"); | |
$xml->startElement("array"); | |
$xml->startElement("dict"); | |
$xml->writeElement("key", "Name"); | |
$xml->writeElement("string", "Best of 2016 Playlist"); | |
$xml->writeElement("key", "Description"); | |
$xml->writeElement("string", "Description of the playlist goes here."); | |
$xml->writeElement("key", "All Items"); | |
$xml->writeElement("true"); | |
$xml->writeElement("key", "Playlist Items"); | |
$xml->startElement("array"); | |
//loop me | |
$xml->startElement("dict"); | |
$xml->writeElement("key", "Track ID"); | |
$xml->writeElement("integer", "1"); | |
$xml->endElement(); | |
$xml->endElement(); | |
$xml->endElement(); | |
$xml->endElement(); | |
$xml->endElement(); | |
$xml->endElement(); | |
/* save xml file */ | |
file_put_contents('xml/test-playlist.xml', $xml->outputMemory()); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment