coding UTF-8 type date 2008-00-00 time file duration import xml dom mi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: UTF-8 -*-
g = {'type': "" , 'date' : "2008-00-00" , 'time' : "" , 'file' : "" , 'duration' : ""}
import xml.dom.minidom
from xml.dom.minidom import Node
a = []
doc = xml.dom.minidom.parse("ait.xml")
for node in doc.getElementsByTagName("item"):
g['type']=itype=node.getAttribute("type")
g['date']=node.getAttribute("date")
g['time']=node.getAttribute("time")
g['file']=node.getAttribute("filename")
g['duration']=node.getAttribute("duration")
if itype == "Movie":
a.append(g)
print g['time']
print a[2]['date']
f=open ('11.html', 'w')
f.write("<html>\n")
f.write("<title>Generated by python</title>\n")
f.write("<Body>\n")
i=1
while i < len(a):
s=str(a[i]['time']+ " ")
f.write(a[i]['time'])
i+=1
f.write("</body></html>\n")
f.close