$(X,\mathcal{O}_X)$ be a locally ringed space, $f\in\mathcal{O}_X(X)$. Show that $D=\{x\in X\mid f(x)\neq0\in\kappa(x)\}\subset X$ is an open subset [duplicate]

Question: "What I have come up with so far is if x∈D then locally near D we will get a g so that fg=1. So, locally f(x)≠0. Am I on the correct path? But I am struggling to use that idea to figure out a formal proof based on my idea. Can somebody help me?"

Answer: If $X:=Spec(A)$ and $\phi_x:A\rightarrow \kappa(x)$ is the canonical map from $A$ to the residue field at the prime ideal $\mathfrak{p}_x$ it follows an element $f\in A$ has $\phi_x(f)\neq 0$ iff $f \notin \mathfrak{p}_x$. Hence the set of prime ideals $\mathfrak{p}_x \subseteq A$ with this property equals the open set $D(f) \subseteq X$.