Skip to main content
https://travis-ci.org/Shoobx/xmldiff.svg?branch=master https://coveralls.io/repos/github/Shoobx/xmldiff/badge.svg

xmldiff is a library and a command-line utility for making diffs out of XML. This may seem like something that doesn’t need a dedicated utility, but change detection in hierarchical data is very different from change detection in flat data. XML type formats are also not only used for computer readable data, it is also often used as a format for hierarchical data that can be rendered into human readable formats. A traditional diff on such a format would tell you line by line the differences, but this would not be be readable by a human. xmldiff provides tools to make human readable diffs in those situations.

Full documentation is on xmldiff.readthedocs.io

xmldiff is still under rapid development, and no guarantees are done that the output of one version will be the same as the output of any previous version.

Quick usage

xmldiff is both a command-line tool and a Python library. To use it from the command-line, just run xmldiff with two input files:

$ xmldiff file1.xml file2.xml

There is also a command to patch a file with the output from the xmldiff command:

$ xmlpatch file.diff file1.xml

There is a simple API for using xmldiff as a library:

from lxml import etree
from xmldiff import main, formatting

diff = main.diff_files('file1.xml', 'file2.xml',
                       formatter=formatting.XMLFormatter())

There is also a method diff_trees() that take two lxml trees, and a method diff_texts() that will take strings containing XML. Similarly, there is patch_file() patch_text() and patch_tree():

result = main.patch_file('file.diff', 'file1.xml')

Changes from xmldiff 0.6/1.x

  • A complete, ground up, pure-Python rewrite

  • Easier to maintain, the code is less complex and more Pythonic, and uses more custom classes instead of just nesting lists and dicts.

  • Fixes the problems with certain large files and solves the memory leaks.

  • A nice, easy to use Python API for using it as a library.

  • Adds support for showing the diffs in different formats, mainly one where differences are marked up in the XML, useful for making human readable diffs.

    These formats can show text differences in a semantically meaningful way.

  • An output format compatible with 0.6/1.x is also available.

  • 2.0 is currently significantly slower than xmldiff 0.6/1.x, but this will change in the future. Currently we make no effort to make xmldiff 2.0 fast, we concentrate on making it correct and usable.

Contributors

The diff algorithm is based on “Change Detection in Hierarchically Structured Information”, and the text diff is using Google’s diff_match_patch algorithm.

Release files for xmldiff 3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xmldiff 3.0
File Size Uploaded
xmldiff-3.0.tar.gz 86.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xmldiff 3.0
File Interpreter ABI Platform
xmldiff-3.0-py3-none-any.whl Python 3 none any Details

Total release size: 129.2 kB

Release files / xmldiff-3.0.tar.gz

Download URL xmldiff-3.0.tar.gz
Size 86.9 kB
Tags Source
SHA-256 checksum
How to use checksums
380ec4d05cef33f5b706cf789abcc848d27730d67e02dc0b4f1107e16ce9aaad
BLAKE2b-256 checksum
How to use checksums
dcf5c2200adb02cb64e5db05bd28fff1032d05d33ac632e3c781142a7aa61bcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.12

Release files / xmldiff-3.0-py3-none-any.whl

Download URL xmldiff-3.0-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6310a765f895b3aa398d16c2283320ceb202f60ea47884495877199ce3a5017b
BLAKE2b-256 checksum
How to use checksums
72beb85bcfd17a163f05674b3c8586d60b9dc8a008f967090b652d3e138ed590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

3.0 This release

2 release files

2.7.0

2 release files

2.6.3

2 release files

2.6.2

2 release files

2.6.1

2 release files

2.6

2 release files

2.5

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

2.0

2 release files

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.6.10

1 release file

0.6.9

1 release file

0.6.8

1 release file

0.6.7

1 release file

0.6.6

1 release file

0.6.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page