code: def base_url(root):
      
      for attr, value in root.attrib.iteritems():
          if attr.endswith('base') and 'http' in value:
              return value
      return None
docs: Determine the base url for a root element.