def _parse_igd_profile(profile_xml):
 try:
  dom = parseString(profile_xml)
 except ExpatError as e:
  raise IGDError('Unable to parse IGD reply: {0} \n\n\n {1}'.format(profile_xml, e))
 service_types = dom.getElementsByTagName('serviceType')
 for service in service_types:
  if ((_get_first_child_data(service).find('WANIPConnection') > 0) or (_get_first_child_data(service).find('WANPPPConnection') > 0)):
   try:
    control_url = _get_first_child_data(service.parentNode.getElementsByTagName('controlURL')[0])
    upnp_schema = _get_first_child_data(service).split(':')[(-2)]
    return (control_url, upnp_schema)
   except IndexError:
    pass
 raise IGDError('Could not find a control url or UPNP schema in IGD response.')

def _parse_igd_profile ( profile_xml ) : try : dom = parseString ( profile_xml ) except ExpatError as e : raise IGDError ( 'Unable to parse IGD reply: {0} \n\n\n {1}' . format ( profile_xml , e ) ) service_types = dom . getElementsByTagName ( 'serviceType' ) for service in service_types : if ( ( _get_first_child_data ( service ) . find ( 'WANIPConnection' ) > 0 ) or ( _get_first_child_data ( service ) . find ( 'WANPPPConnection' ) > 0 ) ) : try : control_url = _get_first_child_data ( service . parentNode . getElementsByTagName ( 'controlURL' ) [ 0 ] ) upnp_schema = _get_first_child_data ( service ) . split ( ':' ) [ ( - 2 ) ] return ( control_url , upnp_schema ) except IndexError : pass raise IGDError ( 'Could not find a control url or UPNP schema in IGD response.' )
traverse the profile xml dom looking for either wanipconnection or wanpppconnection and return the controlurl and the service xml schema .