I'm new to creating XML payloads with TSQL and am having some issues. I'm trying to create a payload that has multiple row detail nested a few rows deep.
Output needs to be formatted this way
will be multiple sotransitem elements
...
I thought i had it all until i realized i needed to have multiple sotransitems. i addressed this by added a subquery to get all the rows for sotransitems.
SELECT TIH.INVOICE_NUM AS "operation/content/create_sotransaction/billto/invoicenumber",
TIH.INVOICE_CUSTOMER_NAME "operation/content/create_sotransaction/billto/customername",
(SELECT TIL.LINE_ITEM_ITEM AS "sotransitem/unit",
TIL.LINE_ITEM_QTY AS "sotransitem/description"
FROM dbo.tblapproved_invc_line AS TIL
WHERE til.LINE_ITEM_INVOICE_NUM = '230065942'
FOR
XML PATH(''), ROOT ('sotransitems'),
TYPE)
FROM dbo.tblapproved_invc_hdr AS TIH
INNER JOIN dbo.tblapproved_invc_line AS TIL
ON TIH.INVOICE_NUM = til.LINE_ITEM_INVOICE_NUM
WHERE til.LINE_ITEM_INVOICE_NUM = '230065942'
FOR XML PATH (''), ROOT('request')
This query gives me all the data, but instead of inserting the data into the xml in the existing
create_sotransaction, it causes all the nodes to close then opens a new set of .
I've tried and my google foo is weak. How would i embed the subquery results without triggering the closing tags of the already open elements?
Trending Articles
More Pages to Explore .....