While they are in the same drug class (benzodiazepine derivatives) and they perform similar functions (act on GABA receptors to cut down on signals flowing through the central nervous system), their chemical structures are very different.
Xanax (generic: alprazolam) is a triazolobenzodiazepine.The chemical name of alprazolam is 8-Chloro-1-methyl-6-phenyl-4H-s-triazolo [4,3-I] [1,4] benzodiazepine.
Valium (generic: diazepam) is 1,4-benzodiazepine. The chemical name of diazepam is 7-chloro-1,3-dihydro-1-methyl-5-phenyl-2H-1,4-benzodiazepin-2-one.
The primary differences:
 half lives (how long they stay active in the body before they are cleaned out)
 valium has a mild muscle relaxant effect that xanax does not