WITH XMLNAMESPACES

  • Hi there everyone. i have a problem. i new at this and trying to generate a XML String using Sql servers FOR XML in sql server 2005. Here is my code

    WITH XMLNAMESPACES('http://URL/AND/SO/ON/' AS ns0)

    SELECT

    (SELECT

    (SELECT

    (SELECT SystemName AS "Contact/UserId",

    GRS_ID AS "Contact/UserOrganisation"

    FROM viewCWTGetContactInfo

    FOR XML PATH('Requester'), TYPE, ELEMENTS),

    (SELECT PartyFunction AS "OrderHead/PartyDetail/PartyFunction",

    PartyIdentifier AS "OrderHead/PartyDetail/PartyIdentifier",

    OrderNo AS "OrderHead/OrderNo",

    Amount AS "OrderHead/TotalValue/Amount",

    Currency AS "OrderHead/TotalValue/Currency",

    DocumentType AS "OrderHead/DocumentType"

    FROM viewCWTGetOrderHeadData

    FOR XML PATH('OrderHeader'), TYPE, ELEMENTS),

    (SELECT OrderItemNo AS "OrderItem/OrderItemNo",

    ExpectedDeliveryDate AS "OrderItem/ExpectedDeliveryDate",

    AmountOrderLine AS "OrderItem/Price/Amount",

    CurrencyOrderLine AS "OrderItem/Price/Currency",

    PaymentMethod AS "OrderItem/PaymentMethod",

    DueDate AS "OrderItem/DueDate" from viewCWTOrderItem

    FOR XML PATH('OrderItem'), TYPE, ELEMENTS)

    FOR XML PATH('CheckParameter'), TYPE, ELEMENTS)

    FOR XML PATH('RequestData'), TYPE, ELEMENTS)

    FOR XML PATH('RequestHead'), ROOT('ns0:ServiceRequest')

    From that i get this

    http://screencast.com/t/SHAk15v1W

    Here is my problem. what i want is to only have (xmlns:ns0=http://URL/AND/SO/ON/>) On my Root Element ( This one ).

    Like this

    http://screencast.com/t/6nCerwjZLgX

    If anyone can tell me what i have done wrong i would be grateful

  • Still need some help with this. please help me if you know how to solve this.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply