As stated this result does not hold. First of all $f$ could be zero in which case "$f(x)=0$" gives no information
whastoever. Even if $f$ is nonzero, it still could be zero on the connected component of its domain containing $\sigma (x)$,
and then "$f(x)=0$" again says nothing.
In order to prove the result it is important to assume that $f$ is not identically zero on any connected component of
its domain.
This said, by the Spectral Mapping Theorem,
$$
\{0\} = \sigma (f(x)) = f(\sigma (x)),
$$
which says that $f$ vanishes on the spectrum of $x$. Because $\sigma (x)$ is compact, and because the set of zeros of an
analytic function satisfying our hypothesis cannot have accumulation points, if follows that $\sigma (x)$ is a finite set.
Writing
$$
\sigma (x) = \{a_1, a_2, \ldots , a_n\},
$$
for every $i=1,2,\ldots ,n$ we let $n_i$ be the (finite) order of $a_i$ as a zero of $f$, so that
$$
f(z)=g(z)\prod_{i=1}^n(z-a_i)^{n_i},
$$
for all $z$, where $g$ is some analytic function defined on the domain of $f$, not vanishing on any $a_i$.
It follows that
$$
0=f(x)=g(x)\prod_{i=1}^n(x-a_i)^{n_i},
$$
but since $g(x)$ is invertible (again by the Spectral Mapping Theorem), we must have that
$\prod_{i=1}^n(x-a_i)^{n_i}=0$, as desired.