There's not much more demoralizing than working for months on a piece of writing only to have it returned to you dripping red ink from your supervisor's comments, especially if you're used to getting good grades from your undergrad days.
It's important not to get too discouraged, though. There are good reasons why feedback gets tougher at PhD level—and ways to cope with it.
Why is critical feedback necessary?
A PhD is all about developing the skills of a professional academic. When a professional academic submits a paper to a journal, it goes through a process of peer review where other academics judge the work and recommend to the journal whether it is worthy of publication and what changes need to be made before publication.
Most journals receive more manuscripts than they can publish, so many are rejected outright by the journal editors without being sent for peer review (every academic will have experienced this at least once, probably several times, in their careers). If the work passes the initial assessment of the editors and is sent to referees, part of their job is to identify any weaknesses in the research, analysis or arguments presented.
Even if your work has been seen by others before you submit it, someone unfamiliar with your work will probably raise concerns you haven't thought of, or they will point out anything that hasn't been properly explained (because it's so familiar to you that it seems obvious). It is vital that you are able to address these concerns when they are valid, and to defend or better explain your work if they are not.
So coping with challenging feedback is an essential part of your PhD training.
PhD vs undergrad feedback
When you submitted essays as an undergraduate student, you will have received a grade and perhaps a few comments. If you scored, say, 90% on a piece of writing that would have been considered excellent, and you would not have had to revise it to make up for the lost 10%.
At PhD level, the system is closer to that of peer-review. The feedback is both tougher and more detailed, and you are expected to respond to it positively.
How to cope with harsh feedback
1- Invite criticism early and often
Don't wait until you have a complete piece of writing before you seek criticism, but try to discuss your work with people before you write it up. Present preliminary ideas, results and analysis and invite criticism as early and as often as possible. If you can get someone to challenge everything, then it not only forces you to strengthen everything, but also to develop the essential skill of criticising your own work from opposing points of view*. By the time you write up your work formally, it will have already been tested and the obvious weak points addressed, meaning that a supervisor or reviewer has to work much harder to find things to criticise.
OK, so there may still be problems with the language and structure, but if the research content is strong then these things can be fixed much more easily than if the writing is OK but the research content weak.
*This is one of the reasons why who you work with is so crucial.
2- Engage with criticism
Even if you have followed step 1 above, your supervisor or reviewer is still likely to raise several points for you to address. It's important not to be disheartened by this, and to engage with the challenge on an academic level with energy and enthusiasm.
Take each point one at a time. For each critical point raised, you need first to understand what point they are making (if unclear, ask), then assess the importance of that specific point (some will be crucial, for example if they question one of your fundamental assumptions, others will be less important). Then you can decide whether you agree or not, and what you need to do in response.
Extreme cases
Most of the time feedback is intended to be constructive, even if it feels like they are attacking everything you say. However, I have heard of cases where supervisors have called students "stupid" (or worse), have yelled at them, or been otherwise abusive towards their students. It's very difficult to know what to do if this happens, as students are often afraid that speaking out will make their lives more difficult. I don't have a solution to suit all of these extreme cases, but I think it's important to realise and remember that a PhD is not everything, and you do not have to stay in an abusive environment.