Find all subdirectories containing xml files on Linux command line

So I don’t forget:

The following Linux command shows a list of all subdirectories that contain a least one *.xml file:

find . -type f -name '*.xml' | sed -r 's|/[^/]+$||' | sort | uniq

This finds all xml files where the extension is all lower case. But since many Windows programs upper case it (and we are talking about a Samba server here), we’d better also search for *.XML:

find . -type f -iname '*.xml' | sed -r 's|/[^/]+$||' | sort | uniq

(The only difference is the “i” in -iname instead of -name.)

This is an adaptation of this answer on unix.stackexchange.com.