Not every SpectrumIdentificationResult containst "scan=" substring in the spectrumID attribute. See specifications of spectrumIDFormat on page 10 of mzIdentML specification. Consider switching to extracting through MS:1001115 element of PSI-MS controlled vocabulary.