Determinant representation for correlation functions of spin-1/2 XXX and XXZ Heisenberg magnets