code: def xml2object(xml, verbose=False):
      
  
      # FIXME - can we allow xml to be string?
      # This would depend on minidom's parse function
  
      # Input tests
      if isinstance(xml, basestring):
          fid = open(xml)
      else:
          fid = xml
  
      try:
          dom = parse(fid)
      except Exception as e:
          # Throw filename into dom exception
          msg = 'XML file "%s" could not be parsed.\n' %fid.name
          msg += 'Error message from parser: "%s"' %str(e)
          raise Exception, msg
  
      try:
          xml_object = dom2object(dom)
      except Exception as e:
          msg = 'Could not convert %s into XML object.\n' %fid.name
          msg += str(e)
          raise Exception, msg
  
      return xml_object
docs: Generate XML object model from XML file or XML text
  
      This is the inverse operation to the __str__ representation
      (up to whitespace).
  
      Input xml can be either an
      * xml file
      * open xml file object
  
      Return XML_document instance.