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

  • Hi,

    It's a bit crude and not very pretty but it does the job!

    DECLARE @xml VARCHAR(4000)

    SELECT @xml = (SELECT name as '@name', xtype as 'data/@field1'

    FROM sysobjects

    FOR XML PATH('object'), ROOT('root'))

    SELECT REPLACE(@xml, ' ')



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]