And the same for compression..
tar caf foo.tar.xz foo/
The extension of the file after the `f` switch tells tar what compression to use.c - compress
a - auto