<s> def xml_compare ( expected , found ) : <EOL> """<STR_LIT>""" <EOL> if expected == found : <EOL> return True <EOL> if set ( expected . items ( ) ) != set ( found . items ( ) ) : <EOL> return False <EOL> expected_children = list ( expected ) <EOL> found_children = list ( found ) <EOL> if len ( expected_children ) != len ( found_children ) : <EOL> return False <EOL> if not all ( [ xml_compare ( a , b ) for a , b in zip ( expected_children , found_children ) ] ) : <EOL> return False <EOL> if ( expected . text is None or expected . text . strip ( ) == "<STR_LIT>" ) and ( found . text is None or found . text . strip ( ) == "<STR_LIT>" ) : <EOL> return True <EOL> else : <EOL> return expected . tag == found . tag and expected . text == found . text and expected . attrib == found . attrib <EOL> def parse_parameters ( param_node ) : <EOL> if param_node . tag == "<STR_LIT>" : <EOL> return param_node . text <EOL> elif param_node . tag == "<STR_LIT>" : <EOL> parameters = [ ] <EOL> for mvp in param_node : <EOL> parameters . append ( mvp . text ) <EOL> return parameters <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % param_node . tag ) <EOL> def parse_xml_data ( parent_node , child_node_tag ) : <EOL> data = { } <EOL> for child in parent_node : <EOL> if child . tag == child_node_tag : <EOL> if child_node_tag == "<STR_LIT>" : <EOL> data [ child . get ( "<STR_LIT:name>" ) ] = { } <EOL> for param in child : <EOL> data [ child . get ( "<STR_LIT:name>" ) ] [ param . get ( "<STR_LIT:name>" ) ] = parse_parameters ( param ) <EOL> elif "<STR_LIT>" == parent_node . tag : <EOL> data [ child . get ( "<STR_LIT:name>" ) ] = parse_parameters ( child ) <EOL> return data </s>
