私が使用しているコードは次のとおりです。
DECLARE @returnXML XML
SELECT @ReturnXML =
(SELECT [StudentID/SSN] = ssn,
[StudentName/LastName] = lastname,
[StudentName/FirstName] = firstname,
[StudentName/MiddleInitial] = Middlename,
[PrimaryAddress/Street1] = line1,
[PrimaryAddress/Street2] = line2,
[PrimaryAddress/City] = city,
[PrimaryAddress/State] = state,
[PrimaryAddress/Country] = ISNULL(country,null),
[PrimaryAddress/Zip] = zipcode
FROM StudentTable
FOR XML Path('Student'), ROOT('Root'),TYPE
)
SELECT @ReturnXML
FOR XML PATH('');
国ノードについてのみ、xsi:nil="true" を設定する必要があります。ありがとう