I am trying to create the following XML document and am having trouble understanding how to do this using TSQL. I have done a lot of research and believe I can do this using XML Path instead of XML Explicit. Any help trying to create the below output would be greatly appreciated. 

Sample Dataset:

```
CREATE TABLE #DataTable
(
PortfolioShortName varchar(20)
,PortfolioLongName varchar(255)
,BenchmarkName varchar(255)
,BenchmarkCode varchar(255)
,PositionGroupName varchar(255)
)
INSERT INTO #DataTable (PortfolioShortName,PortfolioLongName,BenchmarkName,BenchmarkCode,PositionGroupName)
VALUES ('TESTIG','Long Division Short Duration','SP 500','SP.MC.SP500@rmgBenchmarks','Test Strategy'),
('TESTEM','Short Duration Emerging Market','Dow','Dow.MC.Dow@rmgBenchmarks','Test Strategy')

SELECT
*
FROM #DataTable dt

```

XML I am trying to create:

```
<?xml version="1.0" encoding="UTF-8"?>
<positionGroupMetadata xmlns="urn:TestingData-types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:TestingData:1.0:positiongroupmetadata-types file:///C:/Users/BillBill/Desktop/Schemas/positiongroupmetadata-types.xsd">
    <setIdentification>
        <client>Georgia Capital</client>
        <name>Testing Service</name>
        <date>20150924</date>
    </setIdentification>
    <positionGroupItemList>
        <positionGroupItem>
            <positionGroupID type="client">
                <positionGroupValue>TESTIG</positionGroupValue>
            </positionGroupID>
            <tagGroupList>
                <tagGroup>
                    <name>Benchmarks</name>
                    <tagList>
                        <tag>
                            <type>defaultBenchmarkName</type>
                            <value>Long Division Short Duration</value>
                        </tag>
                        <tag>
                            <type>defaultBenchmarkPrimaryIdentifier</type>
                            <value>SP.MC.SP500@rmgBenchmarks</value>
                        </tag>
                    </tagList>
                </tagGroup>
            </tagGroupList>
        </positionGroupItem>
    </positionGroupItemList>
    <positionGroupByWeightList>
        <positionGroupByWeight>
            <positionGroupName>Test Strategy</positionGroupName>
            <positionList>
                <position>
                    <positionGroupID type="client">
                        <positionGroupValue>TESTIG</positionGroupValue>
                    </positionGroupID>
                </position>
                <position>
                    <positionGroupID type="client">
                        <positionGroupValue>TESTEM</positionGroupValue>
                    </positionGroupID>
                </position>
            </positionList>
        </positionGroupByWeight>
    </positionGroupByWeightList>
    <reportSetList>
        <reportSet>
            <reportSetName>DailyReports</reportSetName>
            <reportDataSetList>
                <reportDataSet>
                    <reportDataSetName>TESTIG</reportDataSetName>
                    <positionGroup>
                        <positionGroupIDList>
                            <positionGroupID type="client">
                                <positionGroupValue>TESTIG</positionGroupValue>
                                <holdingGroupAlias>Portfolio</holdingGroupAlias>
                            </positionGroupID>
                        </positionGroupIDList>
                    </positionGroup>
                </reportDataSet>
                <reportDataSet>
                    <reportDataSetName>TESTIG</reportDataSetName>
                    <positionGroup>
                        <positionGroupIDList>
                            <positionGroupID type="client">
                                <positionGroupValue>TESTIG</positionGroupValue>
                                <holdingGroupAlias>Portfolio</holdingGroupAlias>
                            </positionGroupID>
                        </positionGroupIDList>
                    </positionGroup>
                </reportDataSet>
            </reportDataSetList>
        </reportSet>
    </reportSetList>
</positionGroupMetadata>

```

This is as far as I could get. I am not sure how to build the upper list and work my way up the structure.

```
SELECT DISTINCT
        type = 'defaultBenchmarkPrimaryIdentifier'
        ,value = dt.BenchmarkName
        FROM #DataTable dt 

        UNION ALL

        SELECT
        type = 'defaultBenchmarkPrimaryIdentifier'
        ,dt.BenchmarkCode AS defaultBenchmarkPrimaryIdentifier
        FROM #DataTable dt 
        FOR XML PATH('tag'),ROOT('type');

```