The partial discharge caused by the cavity defect in the high voltage cable has intermittent characteristics, the use of X-ray excitation can effectively reduce the statistical delay of discharge, thereby improving the detection rate of defects. The diagnosis and identification of cavity defect types can help to accurately assess their hazards. In this paper, three typical cavity defect models of XLPE/inter-conductor cavity, XLPE internal cavity and XLPE/semiconducting layer cavity are prepared. Partial discharge tests are carried out under X-ray excitation, and the diagnosis and identification methods of defect types are explored. The PRPD spectrogram and TF spectrogram of each model were counted, and the partial discharge phenomenon of each defect model before and after X-ray excitation was observed and compared. The research results show that the PRPD spectrogram and TF spectrogram of the three models are not significantly different, but there are significant differences in the discharge amplitude and duration of the partial discharges of the three models after the X-ray excitation is stopped, which can be easily identified. When the X-ray is extinguished, the partial discharge of the cavity defect in the XLPE disappears immediately after the X-ray excitation is stopped. The partial discharge signal of the XLPE/inter-conductor cavity defect will continue for a period of time after the X-ray excitation is stopped, and the amplitude of the partial discharge is basically maintained. However, the partial discharge signal of the cavity defect between XLPE/semiconductor layer lasts for a period of time after the X-ray excitation is stopped and the partial discharge amplitude gradually decreases.