Filling nextDocument method to parse document