Compare XML two ways

A line diff tells you what bytes changed; a structural diff tells you whether the documents mean the same. You see both, with the equality policy spelled out.

Lexical: 6 − / 7 + linesStructural: 5 differences
Equality policy

Policy in force: ignore formatting whitespace (element-only regions); ignore attribute order; compare names by namespace uri, not prefix; treat cdata as text. Text content is always compared exactly.

SideLineLocationNode
only in A4/config/sec:auth/sec:ttltext "3600"
only in B5/config/s:auth/s:ttltext "7200"
only in A5/config<!-- feature flags -->
only in A7/config/motdtext "Welcome back, "
only in B8/config/motdtext "Welcome back,"

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.