Dear Mavis,
Thanks for contacting Top China Travel!
Firstly, there is only one train travelling between Xian and Dunhuang. The schudule from Xian to Dunhuang is 10:30 to 09:21(+1day). The schedule from Dunhuang to Xian is 09:30to 09:27(+1day). You can book the round trip tickets. It depends on you.
Secondly, there are a couple of ways for your to book train tickets.
Option 1 Booking China Train Ticket Online
The website of China Railway Customer Service Center is www.12306.cn. You can book all domestic trains on this website. However this website is just available in China, and you have to be able to read Chinese. If you can not read Chinese, you may book at http://english.ctrip.com/
Option 2 By telephone
Booking train tickets on phone is available. Bookings Hotline: 95105105 (Do not forget to add the area cord of your departure area in front of it)
Options 3 Directly buy ticket at the Railway Station
If you are already in Xian, you may go to Xian Railway Station directly and buy tickets at the Ticket Office.
Any further request or question, please feel free to contact with us.