Lexical vs structural
Lexical comparison works on lines of text, so re-indenting a file shows up as many changed lines. Structural comparison parses both sides and compares elements, attributes and text in order, so formatting-only changes disappear while a changed value or a moved element stands out.
The policy is yours: ignore formatting whitespace, ignore attribute order, compare names by namespace URI instead of prefix, treat CDATA as text, ignore comments or processing instructions. The current policy is printed above the result so “equal” always says equal under which rules.
Questions
What if one side is not well-formed?
The structural diff refuses and says which side is broken. The lexical diff still works.
Does it align moved elements?
It reports a move as a removal plus an insertion. The alignment is a minimal edit sequence over the parsed node stream.