Creating an XML Document in WSH
(Page 1 of 4 )
An eXtensible Markup Language (XML) file is a simple text-based database system that has been gaining a lot of popularity. Records are stored in a plain text format using a series of custom tags to separate pieces of data. Originally designed for portability and compatibility, these files are becoming commonplace for software engineers and web developers.
Today, I’m going to show you how to create XML files from within your WSH scripts. There are literally endless types of XML files out there. Among other things, they are often used for program configuration files, RSS feeds, web sites, and media playlists.
I’ve chosen to create an XSPF (pronounced “spiff”) playlist. XSPF stands for XML Shareable Playlist Format, an open source play list format designed for its simplicity and portability. The XSPF specification is gaining popularity and is already supported by a number of different media players. You can see an example playlist below.
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<location>file:///URI/to/file.mp3</location>
<title>Song Title</title>
<creator>Artist or Band</creator>
<info>http://link/to/additional/information</info>
<album>Album Title</album>
<trackNum>0</trackNum>
</track>
<track>
<location>file:///URI/to/file.mp3</location>
<title>Song Title</title>
<creator>Artist or Band</creator>
<info>http://link/to/additional/information</info>
<album>Album Title</album>
<trackNum>0</trackNum>
</track>
</trackList>
</playlist>
This is a very basic example of an XSPF playlist—just the bare necessities. A “playlist” element houses a track listing that is made up of multiple “track” elements. I won’t go into too much detail about the specification itself. It’s very simple to figure out, but you can find out more about XSPF by visiting the project home page.
Are you ready to get your hands dirty and get down to code? I thought you might be.
Next: Microsoft’s XML Parser >>
More Windows Scripting Articles
More By Nilpo