#!/home/tjlahton/public_html/cgi-bin/ties4080/venv/bin/python
# -*- coding: utf-8 -*-
from xml.dom.minidom import parse
import urllib.request
print("Content-type: text/plain; charset=UTF-8\n")
try:
doc = parse( urllib.request.urlopen("http://appro.mit.jyu.fi/ties4080/ohjaus/ohjaus6/data.xml"))
except:
print("Ei toimi")
nimi = doc.getElementsByTagName("nimi")[0]
kesto = doc.getElementsByTagName("kesto")[0]
alkuaika = doc.getElementsByTagName("alkuaika")[0]
loppuaika = doc.getElementsByTagName("loppuaika")[0]
print(nimi.firstChild.nodeValue)
print(kesto.firstChild.nodeValue)
print(alkuaika.firstChild.nodeValue)
print(loppuaika.firstChild.nodeValue)
#Kaikki joukkueet
joukkueet = doc.getElementsByTagName("joukkueet")
for j in joukkueet:
nimi = j.getElementsByTagName("nimi")[0]
print(nimi.firstChild.nodeValue)
# joukkueet sarjoittain
sarjat = doc.getElementsByTagName("sarjat")
for s in sarjat:
nimi = s.getElementsByTagName("nimi")[0]
print(nimi.firstChild.nodeValue)
joukkueet = s.getElementsByTagName("joukkueet")
for j in joukkueet:
nimi = j.getElementsByTagName("nimi")[0]
print("\t" + nimi.firstChild.nodeValue)