• Your big mistake was using the RAW option.  That gives you very little control over the output.  You're much better off using the PATH option for most purposes or the EXPLICIT option for very fine control.  Something like the following.  You didn't have multiple accesstypes in your sample data, so I treated the one you did have as two separate ones.

    Of course you can have multiple copies of the same elements at the same level. You just have to be careful to somehow separate them.

    SELECT id AS [file/@id],
        [type] AS [file/@type],
        size AS [file/@size],
        [description],
        stype AS [source/@type],
        sourceid AS [source/@sourceid],
        accesstype as [destination/@type],
        'accessid' AS [destination/@id],
        '' AS [*], /* Separator between destination elements. */
        accesstype as [destination/@type],
        'accessid2' AS [destination/@id]
    FROM ##temp
    FOR XML PATH('MAIN-file')

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA