So I built an export function that allows me to push via an AJAX call an XML file, which starts as following.
if(is_array($result) && (count($result) >