Perfectionists almost always measure their self-worth by their accomplishments, not by their personal qualities. So helping her understand that she is more than the sum of her accomplishments would be a good first step. Point out to her some of her successes from the past and help her identify what role she had in that success. For example, when she learned to ride a bicycle, she might have showed unusual persistence. Or there might have been a project in which she demonstrated a high degree of creativity. She also needs to hear the qualities that you most like about her, whether or not they relate to school.
When she expresses disappointment to you about not being the best, try to listen to her feelings and mirror them back to her rather than focus on the grades themselves. She needs to know that her feelings are what matter the most at that moment, not how she compares to other students in the class. She also needs to know that you and other significant people in her life have experienced the problem of not being the best so she can see that people do survive this and succeed. But be careful not to fall into the trap of praising her to make her feel better about herself -- she will not be able to hear the praise as authentic at the time. Try instead to problem-solve and discover ways she can soothe her sadness, which will provide her with a skill that will last a lifetime! Hope this helps!