#NEWLINE# def _find_elements( self , result , elements ) : #NEWLINE# #INDENT# 'Find interesting elements from XML.\n\n    This function tries to only look for specified elements\n    without parsing the entire XML. The specified elements is better\n    located near the beginning.\n\n    Args:\n      result: response XML.\n      elements: a set of interesting element tags.\n\n    Returns:\n      A dict from element tag to element value.\n    ' #NEWLINE# element_mapping = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# result = StringIO . StringIO ( result ) #NEWLINE# for ( _ , e ) in ET . iterparse ( result , events = ( 'end' , ) ) : #NEWLINE# #INDENT# if ( not elements ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# if ( e . tag in elements ) : #NEWLINE# #INDENT# element_mapping [ e . tag ] = e . text #NEWLINE# elements . remove ( e . tag ) #NEWLINE# #UNINDENT# #UNINDENT# return result