I agree with
dilphinus, there are alot of trains per day passing through so buying on arrival is good enough unless is those cities that are not served by high speed rail (conventional trains) or it's those long distance ones.
If it's those major intercity trains, you can just buy on arrival. Here's the
train schedule between Shanghai to Nanjing. You'll notice a pattern, G and D trains are faster while the rest are slower cause G and D are the inter-city ones or the faster class ones with less stops or whatever (can't remember). There maybe more than one high speed rail train station so make sure when buying tickets (either via counter or online) choose the right station that benefits your destination (use googlemaps to see train station location). This website is very good to see the first and last trains.
Problem with me is I can't read chinese so I queue until I found out I'm in the wrong queue haha... There are some queues for change of timing in case you missed it or want to change for another timing. I really need to improve my chinese..
If you can read chinese just register account and buy online so can choose seats to save alot of hassle. I once chose a 1st class seat and found mcdonald's on the seat left by the previous passenger. I just left it on the floor and sat down. This is just for your info, usually is quite clean.
Longest high speed rail line is Beijing to Guangzhou in 8 hours (according to website). You can read this
website if you're interested in learning more about high speed rail in china. Lots of useful info.
Official China Rail website if I'm not wrong.
Oh yeah I tried the standing ticket once since it was only 1 stop (about 15-20 mins ride).