#NEWLINE# def extract_xml_partial( xml , xpath ) : #NEWLINE# #INDENT# actual = parse_normalize ( actual , to_string = False ) #NEWLINE# nodes = actual . findall ( xpath ) #NEWLINE# root = lxml . etree . Element ( 'partial' ) #NEWLINE# for node in nodes : #NEWLINE# #INDENT# root . append ( node ) #NEWLINE# #UNINDENT# return lxml . etree . tostring ( root , pretty_print = True )