Extract method to convert XML to an array