move xmltoarray to function