FOR XML is generating a empty first line
After a bit of trial and error, I found this is caused by the USE statement occuring after XML mode is turned on. I have no idea why; I assume it's simply an artifact of sqlcmd processing.

Here are three solutions I came up with from playing around with the code:


Remove the USE completely, and specify the database name on the command line using the -d parameter instead.

:XML ON  

SET NOCOUNT ON 

SELECT * FROM ProgramacionDia as programa order by hora 
    FOR XML AUTO, ROOT ('toflash'), ELEMENTS 

SET NOCOUNT OFF

Remove the USE completely, and three-part-name the table.

:XML ON  

SET NOCOUNT ON 

SELECT * FROM [MyDatabaseName]..[ProgramacionDia] as programa order by hora 
    FOR XML AUTO, ROOT ('toflash'), ELEMENTS 

SET NOCOUNT OFF

Move the USE statement above the :XML ON directive, and delete the GO (this will suppress the "Changed database context to 'MyDatabaseName'" message in the output). I have no idea why this also fixes the issue.

USE MyDatabaseName

:XML ON  

SET NOCOUNT ON 

SELECT * FROM ProgramacionDia as programa order by hora 
    FOR XML AUTO, ROOT ('toflash'), ELEMENTS 

SET NOCOUNT OFF



Depending on what your actual script looks like, one of these options should be adaptable for you.