Hi Noam,
let $csv := csv:serialize($result) return file:write-text($out, $csv)
The CVS that comes out only includes one line [...]
As there are unlimited ways to represent XML nodes as CSV, there is no way to automatically a representation that always works best. For more information on creating an XML representation that will yield good results as CSV, please check out the documentation on our CSV Module [1].
Now this works, but I can't seem to find a way to add the headers to the first line of the file.
Obviously, I would recommend you to use the existing CSV features, because it will take care of all the usal nifty details. However, here is one simple way to let your file start with a header line:
file:write-text-lines($out, 'Name,Host,Path,Count,Time'), let $result := concat ($name,',',$host,',',$path,',',$count,',',$time) return file:append-text-lines($out, $result)
Hope this helps, Christian