One of the first goals is to write an XML tree. I found this quite simple and even if I didn't applied any functions (wrote the node one by one) I am guessing I can improve it as time goes by.
So here is the RSS from Keith and the Girl:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!-- TalkCast(TM) feed generated by TalkShow(TM) -->
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<!-- begin RSS 2.0 tags -->
<title>Keith and The Girl</title>
<link>http://www.talkshoe.com/talkshoe/web/tscmd/tc/27183</link>
<language>en-us</language>
<copyright>This work is licensed under a Creative Commons License - Attribution-NonCommercial-ShareAlike - http://creativecommons.org/licenses/by-nc-sa/2.0/</copyright>
<category>Arts & Entertainment</category>
<description>Keith and his girlfriend talk shit. Also visit KeithandTheGirl.com.
This Podcast was created using www.talkshoe.com</description>
<ttl>720</ttl>
<image>
<url>http://www.talkshoe.com/custom/images/icons/TC-27183-MainIcon.jpg</url>
<title>Keith and The Girl</title>
<link>http://www.talkshoe.com/talkshoe/web/tscmd/tc/27183</link>
</image>
<!-- end RSS 2.0 tags -->
<item>
<!-- begin RSS 2.0 tags -->
<title>506: The PaleSkin and FreckleFace Show</title>
<guid>http://recordings.talkshoe.com/TC-27183/TS-25680.mp3</guid>
<pubDate>Wed, 30 May 2007 19:00:00 -0400</pubDate>
<author>info@keithandthegirl.com</author>
<link>http://recordings.talkshoe.com/TC-27183/TS-25680.mp3</link>
<enclosure url="http://recordings.talkshoe.com/TC-27183/TS-25680.mp3" length="68395646" type="audio/mpeg" />
<comments>http://recordings.talkshoe.com/TC-27183/TS-25680.mp3</comments>
<description>That's what you do when a Dee is right there.</description>
<category>Arts & Entertainment</category>
<!-- end RSS 2.0 tags -->
<item>
<!-- begin RSS 2.0 tags -->
<title>505: Girls are Stupid</title>
<guid>http://recordings.talkshoe.com/TC-27183/TS-25435.mp3</guid>
<pubDate>Mon, 28 May 2007 23:59:00 -0400</pubDate>
<author>info@keithandthegirl.com</author>
<link>http://recordings.talkshoe.com/TC-27183/TS-25435.mp3</link>
<enclosure url="http://recordings.talkshoe.com/TC-27183/TS-25435.mp3" length="93006712" type="audio/mpeg" />
<comments>http://recordings.talkshoe.com/TC-27183/TS-25435.mp3</comments>
<description>Can't wait for your spin-off show, Dummy.</description>
<category>Arts & Entertainment</category>
<!-- end RSS 2.0 tags -->
</item>Code: Select all
from xml.dom.minidom import Document
x = Document()
rss = x.createElement("rss")
rss.setAttribute("rss", "2.0")
rss.setAttribute("xml:itunes", "http://www.itunes.com/dtds/podcast-1.0.dtd")
x.appendChild(rss)If I want to do a tree like tags it will be done like this:
Code: Select all
<channel>
<title>Keith and The Girl</title>
</channel>Code: Select all
channel = x.createElement("channel")
rss.appendChild(channel)
title= x.createElement("title")
titleText= x.createTextNode("Keith and the Girl")
channel.appendChild(title)
title.appendChild(titleText)Here is the complete code.