Planes - The fastest way. Be aware that there are two international airports in Shanghai: Shanghai Pudong International Airport and Shanghai Hongqiao International Airport. Flights from Shanghai Pudong International Airport to Guilin take about 2 hours. From the airport take a bus or a taxi to Yangshuo; as described above.
Buses - There is no direct bus link from Shanghai to Yangshuo.
Trains - There is a good service from Shanghai which takes about 24 hours from Shanghai South Railway Station. You can buy tickets for either hard or soft sleepers. Both of these consist of small bunk beds in a shared carriage which are quite comfortable and give quite a good night's sleep.