  We derive a matrix product representation of the Bethe ansatz state for the
XXX and XXZ spin-1/2 Heisenberg chains using the algebraic Bethe ansatz. In
this representation, the components of the Bethe eigenstates are expressed as
traces of products of matrices which act on ${\bar {\mathscr H}}$, the tensor
product of auxiliary spaces. By changing the basis in ${\bar {\mathscr H}}$, we
derive explicit finite-dimensional representations for the matrices. These
matrices are the same as those appearing in the recently proposed matrix
product ansatz by Alcaraz and Lazo [Alcaraz F C and Lazo M J 2006 {\it J. Phys.
A: Math. Gen.} \textbf{39} 11335.] apart from normalization factors. We also
discuss the close relation between the matrix product representation of the
Bethe eigenstates and the six-vertex model with domain wall boundary conditions
[Korepin V E 1982 {\it Commun. Math. Phys.}, \textbf{86} 391.] and show that
the change of basis corresponds to a mapping from the six-vertex model to the
five-vertex model.
