#!/usr/bin/python import urllib, xml.sax hubs=[] req_attrs=[u'Name',u'Address',u'Minshare',u'Users'] class hublist_handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): global hubs if name=='Hub': hubs.append([attrs.getValue(x).encode('iso8859-2','ignore') for x in req_attrs]+['']) def get(url='list.txt'): global hubs hubs=[] if 'http://' in url: f=urllib.urlopen(url,'rt').read().replace('&','_') open('test.txt','wt').write(f) else: f=open(url,'rt').read().replace('&','_') xml.sax.parseString(f, hublist_handler()) return hubs if __name__=='__main__': print get()