Hello. I have been tasked with creating an XML document for my company.
I have used XML in the past for EDI but I have never done XML with attributes. I have googled the past day and have not found many solutions so I figured I would post here.
I was able to figure out how to add the attributes via @vaiable name but I am unable to control the Child/Parent relationship. Here is what I have so far:
select
(select top 1 'TST1' AS [@CompanyID],
'83' AS [@PmtRecCount],
'81400.00' AS [@PmtRecTotal],
'http://www.w3.org/2001/XMLSchema-instance' AS [@xsi]
for xml PATH('File'),
TYPE),
(select top 1 'CHK' AS [@PmtMethod],
'C' AS [@PmtCrDr]
for xml PATH('PmtRec'),
TYPE)
for xml PATH('')
Example of the output: (including the header info)
"