Skip to main content

compare_xml

Try to do a 'xml-comparison' of want and got. Plain string comparison doesn't always work because, for example, attribute ordering should not be important. Ignore comment nodes, processing instructions, document type node, and leading and trailing whitespaces.

def compare_xml(
want: string,
got: string
) - > boolean

Try to do a 'xml-comparison' of want and got. Plain string comparison doesn't always work because, for example, attribute ordering should not be important. Ignore comment nodes, processing instructions, document type node, and leading and trailing whitespaces.

Parameters

NameTypeDescription
wantstringThe expected XML string or fragment to serve as the baseline for comparison
gotstringThe actual XML string or fragment to be validated against the expected structure

Returns

TypeDescription
booleanTrue if the XML structures are semantically equivalent, False otherwise