I had a friend who wanted to stop smoking cannabis and got alprazolam prescribed for that by his doctor (it was in EU). In my opinion it would be better to stick to cannabis than switch to Xanax.
I myself tried talking with my family doctor about my benzo addiction. I was addicted to etizolam, a RC benzo popular at the time. He seemed not to believe me that it was possible to get benzos without a prescription, and told me that I was wrong and couldn't have a benzo addiction.
In Germany these things are really difficult to come by for these minor reasons (it's probably different for the critically ill but I wouldn't know).
Briefly, doctors have to have special permissions to prescribe potentially addictive or mentally altering substances and it's only with a special, bureaucratic kind of prescription ("BtM-Rezept").
That's why I always wonder how this can happen so casually. If I'd ask my GP for benzos for sleep problems I'd most certainly not get them even if he'd be allowed to prescribe them and reckless prescription in this case could lose him his license.