Localizing a divisor on a scheme Fix an integral Noetherian separated scheme $X$ that is regular in codimension 1, then let $D\in\operatorname{Div}X$ be any divisor, then Hartshorne claims that for any point $x\in X$, we can localize the divisor $D$ to obtain some divisor $D_x\in\operatorname{Div}\operatorname{Spec}\mathscr{O}_{X,x}$ in a natural (presumably linear, and possibly surjective) way. But how can we do this? I don't see any sufficiently clear connection between $\operatorname{Spec}\mathscr{O}_{X,x}$ and $X$ to obtain such a map.
 A: This short answer wants to expand Kenny Wong's comment. In Hartshorne, a Weil divisor is a formal sum of irreducible codimension one subschemes. Then, the question reduces to how to localize the latter ones.
Now, fix $U=\mathrm{Spec}(A)$ to be an affine open set containing $x$. If an irreducible codimension one subscheme is contained in $X \setminus U$, we declare its localization at $x$ to be zero. If it is not contained in $X \setminus U$, it corresponds to some prime ideal $\mathfrak{p} \subset A$.
Now, let $\mathfrak{q} \subset A$ be the prime ideal corresponding to the point $x$. In particular, we have $A_\mathfrak{q} \cong \mathcal{O}_{X,x}$. We declare the restriction of the divisor corresponding to $\mathfrak{p}$ to be the prime ideal $\mathfrak{p}\cdot A_\mathfrak{q} \subset A_\mathfrak{q}$.
You can show that this procedure does not depend on the choice of $U =\mathrm{Spec}(A)$. Furthermore, by this construction, you see that prime Weil divisors $D$ such that $x \not \in D$ are exactly the ones whose localization at $\mathcal{O}_{X,x}$ is zero.
