To me this looks like a very manageable itinerary with about the right amount of time to see the various sites you have selected. I'm not sure you'll be able to "explore Shanghai" fully in one afternoon. On the other hand, I would put your time towards what you have done-more in Beijing and Xi'an.
I do not see the Summer Palace on your list of Beijing sites. You might consider that for Wednesday after the Forbidden city, which you should be able to see by lunch time if you get a reasonably early start. Or, perhaps better, go to Beihai Park after the Forbidden City, as they are close to each other. Then spend Day 10 (Friday) at the Summer Palace and the Lama/Confucius Temples. In fact, the metro from the Summer Palace to Lama Temple involves only one change (Line 4 to Line 2) and takes ~40 mins (although a taxi also would work).