HOWEVER......I have weened myself off of them because I don't want to get addicted! Same with Valium, which will also put you to sleep, but can be highly addictive. Once I started CPAP therapy a year ago I put them both on the shelf and now only take one maybe once per week, if I had a bad day and really need a good night's sleep.
So, to address your question exactly; ''Does anyone take Xanax or something similar? If so, do you take it before sleep and if so, does it cause you any problems with sleep apnea?"
Yes, I have taken it off and on for years, before and after getting the CPAP machine. It will surely help you sleep either way, but like many drugs that is just masking and putting a band-aid on the true problem, which will never get cured unless you address the under-lying problem. IE, Apnea. So is it causing a problem? YES.... if you don't bother using the machine you will always have Apnea, Xanax won't cure it by any means.
I'd recommend Melatonin.....after I stopped taking Valiums and Xanax I started on Melatonin [5mg-10mg a night] and it works very similarly, but without the addictive qualities of Xanax. In fact, my DR recommends it and he would never recommend Xanax or even Lunesta, he wants me to fall asleep naturally.