import xml.dom.minidom
xbcdrc_mapping = {
            '006d50a': 'DISPLAY', '0066a05': 'DISPLAY', '0066afd': 'DISPLAY',
            '006e20a': 'REVERSE', '00671f5': 'REVERSE', '006710d': 'REVERSE',
            '006ea0a': 'PLAY', '00675f5': 'PLAY', '006750d': 'PLAY', 
            '006e30a': 'FORWARD', '0067105': 'FORWARD', '00671fd': 'FORWARD', 
            '006dd0a': 'SKIP-', '0066e05': 'SKIP-', '0066efd': 'SKIP-', 
            '006e00a': 'STOP', '00670f5': 'STOP', '006700d': 'STOP', 
            '006e60a': 'PAUSE', '00673f5': 'PAUSE', '006730d': 'PAUSE', 
            '006df0a': 'SKIP+', '0066f05': 'SKIP+', '0066ffd': 'SKIP+', 
            '006e50a': 'TITLE', '0067205': 'TITLE', '00672fd': 'TITLE', 
            '006c30a': 'INFO', '0066105': 'INFO', '00661fd': 'INFO',
            '006a60a': 'UP', '00653f5': 'UP', '006530d': 'UP', 
            '006a70a': 'DOWN', '0065305': 'DOWN', '00653fd': 'DOWN', 
            '006a90a': 'LEFT', '0065405': 'LEFT', '00654fd': 'LEFT', 
            '006a80a': 'RIGHT', '00654f5': 'RIGHT', '006540d': 'RIGHT', 
            '0060b0a': 'SELECT', '0060505': 'SELECT', '00605fd': 'SELECT', 
            '006f70a': 'MENU', '0067b05': 'MENU', '0067bfd': 'MENU', 
            '006d80a': 'BACK', '0066cf5': 'BACK', '0066c0d': 'BACK', 
            '006ce0a': '1', '00667f5': '1', '006670d': '1', 
            '006cd0a': '2', '0066605': '2', '00666fd': '2', 
            '006cc0a': '3', '00666f5': '3', '006660d': '3', 
            '006cb0a': '4', '0066505': '4', '00665fd': '4', 
            '006ca0a': '5', '00665f5': '5', '006650d': '5',
            '006c90a': '6', '0066405': '6', '00664fd': '6',
            '006c80a': '7', '00664f5': '7', '006640d': '7',
            '006c70a': '8', '0066305': '8', '00663fd': '8',
            '006c60a': '9', '00663f5': '9', '006630d': '9',
            '006cf0a': '0', '0066705': '0', '00667fd': '0',
            '0064f0a': 'AUDIO',
            '006af0a': 'ENT.',
            '006d100': 'LT',
            '006890a': 'LAST',
            '006c000': 'MUTE',
            '006e70a': 'A*B',
            '006f90a': 'EXIT',
            '0067f0a': 'D',
            '0068c0a': 'REC'
        }
buttonMap={}
xmlDoc=xml.dom.minidom.parse("buttonMap.xml")                       #   Open the xml button map document
root=xmlDoc.childNodes[0]
remotes=root.childNodes
for remote in xmlDoc.getElementsByTagName('remote'):                #   Traverse each remote node
    prefixNode=remote.getElementsByTagName('eventPrefix')           #   Retrieve remote's prefix to be used
    prefix= prefixNode[0].childNodes[0].data                        #       in the event name
    for button in remote.getElementsByTagName('button'):            #   Traverse each remote's button
        codeNode=button.getElementsByTagName('code')                #   Retrieve the event code
        code=codeNode[0].firstChild.data
        eventNode=button.getElementsByTagName('event')              #   Retrieve the event name
        event=eventNode[0].firstChild.data
        xbcdrc_mapping[str(code)]=str(prefix+'_'+event)

print xbcdrc_mapping                                                #   debugging
