#!/usr/bin/python import urllib2 from xml.dom.minidom import parse URL = 'http://localhost:8080/requests/playlist.xml' xml = parse(urllib2.urlopen(URL)) sap_nodes = [x for x in xml.getElementsByTagName('node') if x.getAttribute('name') in ['TV', 'HDTV', 'Radio', 'TEST'] ] print "#EXTM3U" for sap in sap_nodes: for leaf in sap.getElementsByTagName('leaf'): uri = leaf.getAttribute('uri').replace('rtp://@', '') name = leaf.getAttribute('name') print "#EXTINF:0,%s\nhttp://vpn.ciakt.upjs.sk:8000/rtp/%s" % (name, uri)