Since you're flying in and out of Guangzhou, and you've to visit Seoul in between, be reminded that you'll have to have a double-entry tourist visa instead of the normal single-entry one, or else you'll have to apply for a new one in Seoul before being able to come into China again.
You can take the K82/K83 train from Guangzhou to Xi'an, it leaves at 1700 from Guangzhou and arrives the next day in Xi'an at 1938. There's also the K226/K227 train, but that one takes even longer! Hard sleeper will cost 401-430 RMB and soft sleeper 631/658 RMB; flying would be around 900 RMB!
From Xi'an to Shanghai, I advise flying, as I've seen prices of around 500-600 RMB for this route. However, if you can't get that, the T137/T140 train leaves at 1844 from Xi'an and gets to Shanghai the next day at 1112. Hard sleeper will cost 312-333 RMB and soft sleeper will cost 490/511 RMB.
As for Shanghai to Guangzhou, take the K99 train which leaves at 1024 and arrives at Guangzhou (East) at 1051 the next day. Hard sleeper will cost 355-379 RMB and soft sleeper will cost 558/584 RMB. From the Guangzhou (East) station, you can take an airport shuttle bus to the airport to catch your flight out.