Home Forums Programming XML adding an xml root attribute RE: adding an xml root attribute

  • Since the WITH clause goes before the query, the example above would be:

    with xmlnamespaces('http://ww.w3.org/TR/html4/' as h)

    select getDate() as '@timestamp',

    ( select name as '@name', xtype as 'data/@xtype'

    from sysobjects

    for xml path('object'),type

    )

    for xml path('root')

    (The BOL, especially http://msdn.microsoft.com/en-us/library/ms177400.aspx, has more, and better, examples)

    --Adam