An XSPF file is one XML document. Its root is playlist, defined in section
4.1.1 of the XSPF version 1 specification. This
page covers that element and its children. Tracks are on
Track element, and the rules for
players and generators on
Processing rules.
playlist
| Attribute | Required | Value | Meaning |
|---|---|---|---|
xmlns | yes | http://xspf.org/ns/0/ | The XSPF namespace. It stays at 0 for version 1, because version 1 playlists remain readable by version 0 parsers. |
version | yes | 1 | The version of the format this document follows. The earlier format is 0. |
The element has no other attributes of its own. In a generated playlist the
xml:base attribute can also appear, because
relative URIs are
resolved under XML Base.
Children
The order of the child elements is not fixed by the specification. Where the count is 0 or 1, an element may appear at most once.
| Element | Count | Content | Meaning |
|---|---|---|---|
title | 0 or 1 | text | Human-readable title of the playlist. |
creator | 0 or 1 | text | Human-readable name of the author or group that made the playlist. |
annotation | 0 or 1 | text, no markup | A human-readable comment. “Character data, not HTML”. |
info | 0 or 1 | URI | A web page with more about the playlist, likely the author’s homepage. |
location | 0 or 1 | URI | Where this playlist’s source can be found. |
identifier | 0 or 1 | URI | A canonical, location-independent ID such as a hash. Must be a legal URI. |
image | 0 or 1 | URI | An image to show when no trackList image applies. |
date | 0 or 1 | XML Schema dateTime | Creation date, not last-modified. With no timezone, UTC may be assumed. Example: 2005-01-08T17:10:47-05:00. |
license | 0 or 1 | URI | A resource describing the licence of the playlist. |
attribution | 0 or 1 | list of URIs | Ancestors of this playlist; see below. |
link | 0 or more | URI | A link to a related resource; see below. |
meta | 0 or more | text, no markup | A metadata field; see below. |
extension | 0 or more | nested XML | Application data; see below. |
trackList | exactly 1 | track elements | The list of tracks. Required. |
trackList
trackList is an ordered list of
track elements, and it
may be empty. The order is a hint: a player is advised to play the tracks from top to
bottom unless told otherwise.
attribution
An ordered list of URIs, used to meet licences that require attribution of modified
works. The specification’s example shows location and
identifier children, each holding a URI.
<attribution>
<location>http://bar.com/modified_version_of_original_playlist.xspf</location>
<identifier>somescheme:original_playlist.xspf</identifier>
</attribution>
When a playlist is modified, its own location or
identifier moves to the top of the attribution list. The specification
suggests dropping entries more than ten generations back.
link, meta and extension
These three let a playlist carry things the specification does not define. They work identically at playlist and track level.
| Element | Attribute | Attribute value | Content |
|---|---|---|---|
link | rel | URI of a resource type | URI of a resource of that type. |
meta | rel | URI defining the metadata | Plain text. It may not contain markup. |
extension | application | URI defining the structure and purpose of the nested XML | Arbitrary nested XML, which link and meta cannot hold. |
<link rel="http://foaf.example/namespace/version1">http://socialnetwork.example/foaf/mary.rdfs</link>
<meta rel="http://example.org/key">value</meta>
<extension application="http://example.com">
<cl:clip start="25000" end="34500" xmlns:cl="http://example.com"/>
</extension>
A complete document
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Road trip</title>
<creator>Mary Example</creator>
<annotation>Songs for a long drive.</annotation>
<info>http://example.com/mary/</info>
<location>http://example.com/mary/roadtrip.xspf</location>
<identifier>urn:uuid:0d83f5e9-4a6f-4b27-9f15-2a5c9f8a6b01</identifier>
<image>http://example.com/mary/roadtrip.jpg</image>
<date>2005-01-08T17:10:47-05:00</date>
<license>http://creativecommons.org/licenses/by/4.0/</license>
<trackList>
<track>
<location>http://example.com/song_1.ogg</location>
<title>First Song</title>
<creator>Artist Name</creator>
<duration>215000</duration>
</track>
</trackList>
</playlist>