Html_To_NodeTable
Returns tabular hierarchical data representation of an HTML document
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT *
FROM SQLHTTP.net.Html_To_NodeTable( @Html )
Name | Type | Description |
---|---|---|
@Html | nvarchar(MAX) | An HTML string |
See NodeTable for detailed table structure documentation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
DECLARE @Html nvarchar(MAX) SET @Html = '<html> <head> <title>Sample Page</title> </head> <body> <img src="image.png"> </body> </html>' SELECT RowID, ParentRowID, NodePath, NodeType, [Name], LEFT(REPLACE([Value], CHAR(13) + CHAR(10), ''), 20) + '...' AS PartialHtmlTable FROM SQLHTTP.net.Html_To_NodeTable(@Html) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
RowID ParentRowID NodePath NodeType Name PartialHTMLTable ------ ------------ ----------------------------------------- ---------- ---------- -------------------------------- 1 0 #document Document #document <html> <head> ... 2 1 #document/html{1} Element html <html> <head> ... 3 2 #document/html{1}/text(){3} Text NULL ... 4 2 #document/html{1}/head{1} Element head <head> <title... 5 4 #document/html{1}/head{1}/text() Text NULL ... 6 4 #document/html{1}/head{1}/title{1} Element title <title>Sample Page</... 7 6 #document/html{1}/head{1}/title{1}/text() Text NULL Sample Page... 8 4 #document/html{1}/head{1}/text(){2} Text NULL ... 9 2 #document/html{1}/text() Text NULL ... 10 2 #document/html{1}/body{1} Element body <body> <img s... 11 10 #document/html{1}/body{1}/text(){2} Text NULL ... 12 10 #document/html{1}/body{1}/img{1} Element img <img src="image.png"... 13 12 #document/html{1}/body{1}/img{1}/@src Attribute src image.png... 14 10 #document/html{1}/body{1}/text() Text NULL ... 15 2 #document/html{1}/text(){2} Text NULL ... |