Cheap and small alternative to optoisolators: is there any?
There are no safety reasons (I just need to transmit the signal from neutral to line).


Just to be clear, no safety reasons should also mean that no user will be able to access any part of the system that is connected (directly or indirectly) to the "high voltage" system. It also means that the construction of the system is designed for fire safety as if it were all connected directly to the high voltage.

It means that the entire system will be designed as if all of it is at "high" voltage at all times, as far as fire and shock hazards are concerned.


  I just need to transmit the signal from neutral to line


If this means you want to superimpose a data signal on to a mains wire pair, then AFAIK the usual way is to use a transformer. Since relatively low is required, it doesn't necessarily have to be very big or pricey.


  Capacitor can be cheap and small solution, but it will not work on DC.


Finding a solution that works at DC will be very difficult, since mains frequencies are very close to DC compared to the message signal in most data communications situations. 

Consider modulating your message signal to some higher frequency to enable separating out the message frequency band from the mains frequency.