Compare two XML documents

Compare two XML trees and report added, removed, changed, and type-changed paths.

freeworks offlinenothing uploaded
ToolXML Diff
Input
Output

How it works

Both documents are parsed into object trees, keys are compared recursively, arrays are matched by index, and primitive or type changes become path-based differences. Aggregate counts classify added, removed, and changed nodes.

  • Object keys match by name while repeated elements use positions.
  • Parsing focuses on structure rather than source formatting.

Worked example

Server config with changed host and port
Compare two XML server configs to find changed values, removed elements, and new additions
Input
											Input1: <config>
  <host>localhost</host>
  <port>8080</port>
  <debug>true</debug>
</config>
Input2: <config>
  <host>production.example.com</host>
  <port>443</port>
  <ssl>true</ssl>
</config>
										
Output
												Path            Type     Old value  New value
--------------  -------  ---------  ----------------------
$/config/host   changed  localhost  production.example.com
$/config/port   changed  8080       443
$/config/debug  removed  yes
$/config/ssl    added               yes
											

When to use this

SOAP regressions, configuration migrations, and XML fixture reviews compare structures.

Edge cases

  • Reordering repeated elements appears as index changes.
  • Attribute order and insignificant whitespace can disappear during parsing.
  • Text-to-number changes are type changes in the parsed tree.

References