Buenas... Preciso me de una mano con la serialización de xml en python, preciso crear desde un archivo xml todos los objetos pertinentes, y al reves desde un objeto python crear el xml.
 
He estado haciendo lo siguiente:    
Código Python:
Ver originalclass XML2Py():
 
    def __init__( self ):
 
        self._parser = parser = etree.XMLParser( remove_blank_text=True )
        self._root = 'DHA'  # root de la estructura etree 
        self.data = 'Nivel'   # Estructura donde precesamos los datos Python 
 
    def parse( self, xmlString ):
        '''        procesa string xml dentro de una estructura de datos Python
        '''
        self._root = etree.fromstring( xmlString, self._parser )
        self.data = self._parseXMLRoot()
        return self.data
 
    def tostring( self ):
        '''
        crea una representación de string usando el objeto etree
        '''
        if self._root != None:
            return etree.tostring( self._root )
 
    def _parseXMLRoot( self ):
        '''
        comienza a procesar, tener cuidado en el primer nivel de serializacion
        '''
        childDict = self._parseXMLNode( self._root )
        return { self._root.tag : childDict["children"] }
 
    def _parseXMLNode( self, element ):
        '''
        resto del procesamiento
        '''
        childContainer = None # either Dict or List
 
        # process any tag attributes
        # if we have attributes then the child container is a Dict
        #   otherwise a List
        if element.items():
            childContainer = {}
            childContainer.update( dict( element.items() ) )
        else:
            childContainer = []
 
 
        if isinstance( childContainer, list ) and element.text:
            # tag with no attributes and one that contains text
            childContainer.append( element.text )
 
        else:
            # tag might have children, let's process them
            for child_elem in element.getchildren():
 
                childDict = self._parseXMLNode( child_elem )
 
              # let's store our child based on container type
                #
                if isinstance( childContainer, dict ):
                    # these children are lone tag entities ( eg, 'copyright' )
                    childContainer.update( { childDict["tag"] : childDict["children"] } )
 
                else:
                    # these children are repeated tag entities ( eg, 'format' )
                    childContainer.append( childDict["children"] )
 
        return { "tag":element.tag, "children": childContainer }
 
 
def main():
 
    archivoxml = minidom.parse('tentativoXML.xml') # Uso la función par de minidom para cargar en una variable el contenido del archivo xml
    xml_string = archivoxml.toxml() # Paso los datos del archivo para sean procesados como string
    deserializer = XML2Py()
    python_object = deserializer.parse( xml_string )
    print xml_string
    print python_object
 
if __name__ == '__main__':
    main()
  
Pero me genera problemas, ya que me quedan elementos a los cuales no les deja el nombre del tag, sino que les pone un numero.   
 
Espero puedan ayudar. Saludos