Maybe you should try taking her to a therapist instead of just a pediatrician.
Punishment wont help in fact if you have been punishing her it may have made the problem worse and caused anxiety.Best to be patient and find out the WHY of it.What does the school say how do they cope with the issue or does she only do it at home ? Anything you can think of may be upsetting her,did none of the doctors think it may be an emotional issue ?