Xml_To_NodeTable
Returns tabular hierarchical data representation of an XML
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT *
FROM SQLHTTP.net.Xml_To_NodeTable( @Xml )
Name | Type | Description |
---|---|---|
@Xml | xml | An XML to be shredded into a table |
See NodeTable for detailed table structure documentation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
DECLARE @X xml SET @X = '<?xml version="1.0" encoding="UTF-8"?> <DocumentElement param="value"> <FirstElement> ¶ Some Text </FirstElement> <?some_pi some_attr="some_value"?> <SecondElement param2="something"> Pre-Text <Inline>Inlined text</Inline> Post-text. </SecondElement> </DocumentElement>' SELECT * FROM SQLHTTP.net.Xml_To_NodeTable(@X) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
RowID ParentRowID NodePath NodeType Name Value ------- ------------ ------------------------------------------------- ----------------------- ---------------- -------------------------- 1 0 DocumentElement Element DocumentElement <DocumentElement param="... 2 1 DocumentElement/@param Attribute param value 3 1 DocumentElement/FirstElement{1} Element FirstElement <FirstElement> ... 4 3 DocumentElement/FirstElement{1}/text() Text NULL ¶ Some Text 5 1 DocumentElement/some_pi{1} ProcessingInstruction some_pi some_attr="some_value" 6 1 DocumentElement/SecondElement{1} Element SecondElement <SecondElement param2="s... 7 6 DocumentElement/SecondElement{1}/@param2 Attribute param2 something 8 6 DocumentElement/SecondElement{1}/text() Text NULL Pre-Text 9 6 DocumentElement/SecondElement{1}/Inline{1} Element Inline <Inline>Inlined text</In... 10 9 DocumentElement/SecondElement{1}/Inline{1}/text() Text NULL Inlined text 11 6 DocumentElement/SecondElement{1}/text(){2} Text NULL Post-text. |