Since having asked this question I know feel I understand the meaning:
Firstly the matrix element can only really be understood within a corresponding matrix equation such as:
$$\langle \psi |\hat{O}|\psi\rangle=\int \mathrm dx \int \mathrm dx' \langle \psi |\,x'\rangle \langle x' |\hat{O}|\,x\rangle \langle x\, |\,\psi\rangle $$
Now in non relativistic QM $\hat{O}=f(\hat{p},\hat{x})$ i.e. the operator can be written as some function of momentum and position operators. Firstly the simplest case is if $\hat{O}=f(\hat{x})$ then we have
\begin{align}&=\int \mathrm dx \int \mathrm dx' \langle \psi |\,x'\rangle \langle x' |\,f(\hat{x})|\,x\rangle \langle x\, |\,\psi\rangle \\&= \int \mathrm dx \int \mathrm dx' \langle \psi |\,x'\rangle f(x)\langle x' |\,x\rangle \langle x\, |\,\psi\rangle \\ &= \int \mathrm dx \int\mathrm dx' \langle \psi |\,x'\rangle f(x)\delta(x-x') \langle x\, |\,\psi\rangle \end{align}
Next we can consider the case when $\hat{O}=f(\hat{p})$:
\begin{align}&=\int\mathrm dx \int \mathrm dx' \langle \psi |\,x'\rangle \langle x' |\,f(\hat{p})|\,x\rangle \langle x\, |\,\psi\rangle\\ & = \int\mathrm dp \int\mathrm dx \int\mathrm dx' \langle \psi |\,x'\rangle f(p)\langle x' |\,p\rangle\langle p\, |x\rangle \langle x\, |\,\psi\rangle \\& = \int \mathrm dp \int\mathrm dx \int\mathrm dx' \langle \psi |\,x'\rangle f(p)e^{-ip(x'-x)/\hbar} \langle x\, |\,\psi\rangle \\& = \int \mathrm dp \int \mathrm dx \int \mathrm dx' \langle \psi |\,x'\rangle f\left(-i\hbar\frac{\partial}{\partial x'}\right)e^{-ip(x'-x)/\hbar} \langle x\, |\,\psi\rangle \\ &= \int \mathrm dx \int \mathrm dx' \langle \psi |\,x'\rangle f\left(-i\hbar\frac{\partial}{\partial x'}\right)\delta(x-x') \langle x\, |\,\psi\rangle \\&= \int \mathrm dx' \langle \psi |\,x'\rangle f\left(-i\hbar\frac{\partial}{\partial x'}\right) \langle x'\, |\,\psi\rangle \end{align}
Hence we have again related the matrix form of the operator to its corresponding differential operator in the position representation. This process can be generalised for any product of operators $\hat{p}$ and $\hat{x}$ and so in general we see that:
$$\langle x' |\hat{O}|\,x\rangle=\langle x' |f(\hat{x},\hat{p})|\,x\rangle=f\left(x',-i\hbar\frac{\partial}{\partial x'}\right)\delta(x-x')\,.$$