def main(): file = open("test.xml","r") line = file.readline() while not startDevices(line): line = file.readline() line = file.readline().strip() devices = [] device = "" group = "" capability = "" while not endDevices(line): if beginDevice(line): line = deleteTags(line,"<device ",">") att_id = getAttrId(line) att_user = getAttrUser(line) att_fall = getAttrFall(line) device = Device(att_id, att_user, att_fall) line = file.readline() if endDevice(line): devices.append(device) line = file.readline() if beginGroup(line): line = deleteTags(line,"<group ",">") att_id = getAttrId(line) group = Group(att_id) group.setDevice(device) line = file.readline() if endGroup(line): device.addGroup(group) line = file.readline() if beginCapability(line): line = deleteTags(line, "<capability ", "/>") att_name = getAttrName(line) att_value = getAttrValue(line) capability = Capability(att_name, att_value) capability.setGroup(group) group.addCapability(capability) line = file.readline() print "Devices\n" printDevices(devices) print "End Devices\n" file.close() return 0