I have following XML code snippet and I am trying to read it in tabular format using SQL Server.
declare @ProductXML varchar(max);
set @ProductXML = '<hashtable> <entry>
<string>host</string>
<string-array>
<string>csdfs</string>
</string-array>
</entry>
<entry> <string>dom</string><map-array>
<map>
<entry>
<string>thirdlevelentrey</string>
<vector>
<string>1in</string>
<string>2in</string>
<string>3in</string>
<string>4in</string>
<string>5in</string>
</vector>
</entry>
</map>
</map-array></entry>
</hashtable>'
DECLARE @xml xml
SELECT @xml = CAST(CAST(@ProductXML AS VARBINARY(MAX)) AS XML)
SELECT
x.Rec.query('./string').value('.', 'nvarchar(50)') AS 'Product Name',
x.Rec.query('./vector/string').value('.', 'nvarchar(50)') AS 'Product TLDs'
FROM
@xml.nodes('/hashtable/entry/map-array/map/entry') AS x(Rec)
I am facing the issue with second column Product TLDs. In under the vector multiple rows value merged in single text. I want them with separator or delimited text so I could recognize them later when I use.
If someone can help me to place a separator or deliminator such as 1in|2in|3in and so on...
or can it be possible to in a child table considering thirdlevelentry as a table.