Home Forums Programming XML XML schema - Element name used to identify item problem... RE: XML schema - Element name used to identify item problem...

  • That's my "wild-guessing-code" that might help you:

    SELECT

    c.value('TRANS_CODE[1]', 'VARCHAR(30)') AS Batches_col1

    FROM @xml.nodes('//HEADER') t(c)

    SELECT

    c.value('CLIENT_SSN[1]', 'VARCHAR(30)') AS Clients_col1

    FROM @xml.nodes('//RECORD') t(c)

    SELECT

    v.value ('@id[1]','VARCHAR(50)') AS Charges_col1,

    y.value('local-name(.)', 'VARCHAR(50)') AS Charges_col2,

    y.value('(.)', 'VARCHAR(50)') AS Charges_col3

    FROM @xml.nodes('//RECORDS') t(c)

    CROSS APPLY

    t.c.nodes('RECORD') u(v)

    CROSS APPLY

    u.v.nodes('*') x(y)

    WHERE y.value('local-name(.)', 'VARCHAR(50)') LIKE '%CHARGES'



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]