def parse_elements(valid_els, inner_els, element):
 result = {}
 for sub in element:
  t = fixtag(sub.tag, NS_MAP)[0]
  if (':' in t):
   t = t.split(':')[1]
  if (t in valid_els):
   result[t] = (sub.text or '')
  elif (t in inner_els.keys()):
   inner_result = inner_els[t](sub)
   if isinstance(inner_result, tuple):
    result[inner_result[0]] = inner_result[1]
   else:
    result[t] = inner_result
   m = re.match('([a-z0-9-]+)-list', t)
   if (m and ('count' in sub.attrib)):
    result[('%s-count' % m.group(1))] = int(sub.attrib['count'])
  else:
   _log.info('in <%s>, uncaught <%s>', fixtag(element.tag, NS_MAP)[0], t)
 return result

def parse_elements ( valid_els , inner_els , element ) : result = { } for sub in element : t = fixtag ( sub . tag , NS_MAP ) [ 0 ] if ( ':' in t ) : t = t . split ( ':' ) [ 1 ] if ( t in valid_els ) : result [ t ] = ( sub . text or '' ) elif ( t in inner_els . keys ( ) ) : inner_result = inner_els [ t ] ( sub ) if isinstance ( inner_result , tuple ) : result [ inner_result [ 0 ] ] = inner_result [ 1 ] else : result [ t ] = inner_result m = re . match ( '([a-z0-9-]+)-list' , t ) if ( m and ( 'count' in sub . attrib ) ) : result [ ( '%s-count' % m . group ( 1 ) ) ] = int ( sub . attrib [ 'count' ] ) else : _log . info ( 'in <%s>, uncaught <%s>' , fixtag ( element . tag , NS_MAP ) [ 0 ] , t ) return result
extract single level subelements from an element .