We most often buy our train tickets from https://www.travelchinaguide.com/china-trains/.
It is easy to find the departure and destination, date, number of people, etc. You can pay with a non-Chinese credit card. When it comes time to press the Book button be sure to have your passports ready. Fill in your name exactly as it is in your passport. If you have three names, for example, but only use the first, then do not just put the first name down plus surname. Put down ALL your names, and in the order they appear in the passport. Ours is Last Name, Names. I find using ALL CAPS to be helpful for the train staff to read the ticket and the passport when picking up the ticket, or on the train. You will need to go to the departure station before your trip to pick up the tickets. We've bought tickets within a few hours of departure and were able to pick up the tickets. It's easier and less stressful if you can do it days in advance. In that case you don't need to go to the station necessarily but a ticket booth. But not all ticket booths will issue train tickets to expats.... so you might end of going to the train station anyway. At the very least, give yourself a few hours before your departure to go to the station to get the tickets. It may take a while to find the correct hall, and the correct window, plus security checks slow things down.
The site will say it can't guarantee you will be beside each other, but in all of our trips, buying four tickets, we have always been beside each other, both in the the 4-berth sleeper cabins, and soft seat cabins.
Other than this easy site, I'd suggest using a travel service, in which case you will need to color scan your passports and email them the jpgs. Their employee will buy it in person and can ensure you are together. But I am unable to suggest an agency in Xi'an.
If you are in China, then you can go yourself to the train station, or ticket booth authorized to issue tickets to foreigners. You will need your original passports, renminbi (no expat credit card this time), and the numbers of the trains you want to buy tickets for. I say "numbers" because the one you want may be full, so rather than getting flustered trying to figure out on their tiny train schedule boards what suits you best, you can use the web site I cited above to figure out which trains you prefer, and write their numbers and departure times down and bring them with you to the train station or ticket booth.