Also, whatever you do, please consider electrical safety.
It is in general easy to find transformers specified to withstand mains voltage safely. With a capacitive connection you have to use capacitors classified as "Y" capacitors, if they are between mains and user accessible circuits. With resistors one has to have sufficient voltage ratings, and usually several in series.
Using optical isolation may be one of most elegant, but it is often not very simple. And you have to use optoisolators fulfilling the safety requirements.