XML Getting Started
Compare two XML documents from Base and Contrast through result navigation, Git Diff, URL loading, and sharing.
Compare XML compares parsed elements, attributes, and text instead of treating an XML document only as lines of text. This guide walks through a configuration review, from entering Base and Contrast to interpreting the result and sharing it safely.
Start with Base and Contrast
The two editors have a direction:
| Editor | Put here | Typical examples |
|---|---|---|
| Base | The original or reference document | The deployed configuration, an expected SOAP response, data before transformation |
| Contrast | The document you want to check against it | The proposed configuration, an actual SOAP response, data after transformation |
An element or attribute found only in Contrast is Added. One found only in Base is Deleted. Swapping the inputs exchanges those categories and reverses the before-and-after values of a change.
A complete example
Suppose you are reviewing a service catalog before deployment. Paste this document into Base:
<?xml version="1.0" encoding="UTF-8"?>
<catalog environment="production">
<!-- Currently deployed service -->
<service name="billing" enabled="true">
<endpoint protocol="https">https://billing.example.com/api</endpoint>
<limits>
<requests>100</requests>
<timeout>2.5</timeout>
</limits>
<region>us-east</region>
<region>eu-west</region>
<description><![CDATA[Primary billing service]]></description>
</service>
</catalog>
Paste the proposed document into Contrast:
<?xml version="1.0" encoding="UTF-8"?>
<catalog environment="production">
<!-- Proposed service configuration -->
<service name="billing" enabled="true">
<endpoint protocol="https">https://billing.example.com/api</endpoint>
<limits>
<requests>150</requests>
<timeout>2.50</timeout>
</limits>
<region>us-east</region>
<region>eu-west</region>
<region>ap-south</region>
<description><![CDATA[Primary billing API]]></description>
</service>
</catalog>
For this walkthrough, select By Index for repeated elements and leave both case options off. The request limit and description change, and the third region is added. The timeout values 2.5 and 2.50 compare as the same number; the changed comments do not create differences.
Enter the XML
Open Compare XML and use either editor to:
- paste a complete, well-formed XML document;
- drag and drop an XML file, or use the file-loading action;
- import XML from an HTTP/HTTPS URL. A GitHub Gist page URL is resolved to its raw file content.
For URL imports, the source must be publicly accessible to your browser, return XML or plain text, and allow the browser request through CORS. A successful download can still contain invalid XML.
Parsing and comparison run locally in your browser. Importing from a URL contacts the source you specify; read the privacy note below before using Share or placing data in a URL.
Choose comparison rules
Use Settings next to Compare to select the rules that match your data:
- By Index, LCS, or Unordered controls how repeated child elements are matched.
- Ignore Element/Attribute Name Case treats names such as
Serviceandserviceas equivalent. - Ignore Value Case compares text and attribute values without case sensitivity.
Numeric-looking values are converted to numbers automatically; there is no separate numeric-string switch. Comments are ignored and CDATA contributes text. See XML Comparison Rules for examples, duplicate handling, and the namespace-prefix limitation.
Run the comparison
Select Compare. Both inputs are validated and parsed, then their structures are compared recursively. The result page opens at /tools/compare-xml/result in Data Compare view.
The example reports Value Changed for the request limit and CDATA text, and Added for the new region. Result categories have these meanings:
- Added (green): an element, attribute, or value exists only on the Contrast side.
- Deleted (red): an element, attribute, or value exists only on the Base side.
- Value Changed (yellow): corresponding values differ.
Same means the parsed documents are equal under the currently selected rules. It does not mean the original XML text is byte-for-byte identical.
Read the normalized result
The Data Compare sidebar groups differences by category and shows full paths. Select an entry to reveal its location in the aligned editors, or use the category controls to focus the review.
Data Compare renders XML reconstructed from the parsed values. Consequently, its indentation, line layout, numeric spelling, comments, and CDATA presentation can differ from the source you entered. It is a normalized result view, not a verbatim copy of the input.
Use the two views for different questions:
- Data Compare asks what changed in the parsed XML under the selected rules.
- Git Diff asks what changed in the original text entered into each editor. It can show comment, formatting, and numeric-spelling edits that Data Compare intentionally treats as equal.
On the result page, semantic Settings are available in Data Compare. Switch back from Git Diff to change them and recalculate the structural result.
Sharing and sensitive data
Entering or pasting XML for comparison does not upload it. Parsing and comparison run locally in your browser. Using Share uploads the compared content to the share server and creates a link to /tools/compare-xml/result with a share_id; anyone with that link can load the stored snapshot until it expires.
Data placed in URL query parameters is sent with page requests and may be recorded in hosting logs, so do not place sensitive data in URLs. This applies to Base64-encoded XML as well as remote source addresses. Importing from a URL also sends a request to the source you specify.
Troubleshooting
An editor reports invalid XML
Check both inputs for mismatched tags, unescaped & characters, missing quotes around attributes, and text outside the document. Remove surrounding log output or HTTP headers so each editor contains only well-formed XML.
One insertion causes many repeated-element changes
By Index compares positions, so an insertion can shift every later sibling. Use LCS when order matters and existing elements should remain aligned across insertions and deletions. Use Unordered only when order has no meaning; duplicate occurrence counts still matter.
An expected change is missing
Review the active case options and repeated-element method. Remember that comments are ignored, CDATA is compared as text, and numeric-looking values become numbers. A hidden result category can also conceal entries in the current sidebar view. Switch to Git Diff when you need to audit the exact source text.
A URL import fails
Confirm that both the Base and Contrast parameters or editor imports use accessible HTTP/HTTPS URLs. Check the response content type, XML validity, authentication requirements, and CORS policy. For a Gist, verify that the link identifies accessible content.
Read XML Comparison Rules to choose options deliberately rather than simply making the diff smaller.
Browse the documentation
Find practical guides for comparison options, sharing, browser extensions, AI assistants, and language libraries.
Work with XML
Follow an XML-aware workflow, choose comparison rules, and inspect text changes.
Load, share & work offline
Open XML comparisons from links, share snapshots, or install the app.
Use editor & AI integrations
Compare XML in VSCode or give coding assistants a verified XML diff tool.
Build with XML libraries
Add semantic XML comparison to JavaScript apps, scripts, and CI.