This line should go in the end of the 'if (isMultiStatus)' block. The 'result' object is not really defined until the processing of the multistatus response is finished.