Array Comparison Methods

XML elements often contain repeated child elements. Depending on whether order matters, how you want insertions and deletions reported, and whether duplicates are significant, Compare XML offers three array comparison methods.

By Index

Each child element is compared to the element at the same position in the other parent.

<!-- Base -->
<items>
  <item>A</item>
  <item>B</item>
  <item>C</item>
</items>

<!-- Contrast -->
<items>
  <item>A</item>
  <item>C</item>
  <item>B</item>
</items>

With By Index, the second and third positions are both reported as changed because B became C and C became B. This method is the strictest and works best when child elements are ordered and positional alignment is expected, such as sorted lists or fixed-size sequences.

LCS (Longest Common Subsequence)

LCS finds the longest ordered sequence of elements that appears in both parents. Elements inside that sequence are considered unchanged, while elements outside it are reported as inserted or deleted.

<!-- Base -->
<items>
  <item>1</item>
  <item>2</item>
  <item>3</item>
  <item>4</item>
</items>

<!-- Contrast -->
<items>
  <item>1</item>
  <item>3</item>
  <item>4</item>
  <item>5</item>
</items>

With LCS, 1, 3, and 4 form the common subsequence, so 2 is reported as deleted and 5 as added. LCS is useful when child elements are mostly ordered but may have values inserted or removed in the middle, such as changelog entries or ordered event logs.

Unordered

Child elements are compared as a set, ignoring order and duplicate values.

<!-- Base -->
<items>
  <item>1</item>
  <item>2</item>
  <item>2</item>
  <item>3</item>
</items>

<!-- Contrast -->
<items>
  <item>3</item>
  <item>1</item>
  <item>2</item>
</items>

With Unordered, these elements are considered the same because they contain the same unique values. If one side contains 4 and the other does not, 4 is reported as added. This method is ideal when child elements represent collections where order does not matter, such as tag lists or permission sets.

Choosing a Method

Use caseRecommended method
Ordered sequences, sorted listsBy Index
Ordered lists with occasional insertions or deletionsLCS
Sets, tags, permissions, categoriesUnordered

You can change the array comparison method in the Settings panel before running a comparison.