HtmlNodeCount
Returns the highest available Index that can be used using the HTMLNode function.
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.HtmlNodeCount ( @Html, @Xpath )
Name | Type | Description |
---|---|---|
@Html | nvarchar(MAX) | String containing HTML |
@Xpath | nvarchar(MAX) | An Xpath query |
int
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
DECLARE @Html nvarchar(MAX) DECLARE @Xpath nvarchar(MAX) SET @Html = N' <table align="center"> <thead> <tr> <th>Year</th> <th>Start date</th> <th>Ending date</th> </tr> </thead> <tbody> <tr> <td>2017</td> <td>March 12</td> <td>November 5</td> </tr> <tr> <td>2018</td> <td>March 11</td> <td>November 4</td> </tr> <tr> <td>2019</td> <td>March 10</td> <td>November 3</td> </tr> <tr> <td>2020</td> <td>March 8</td> <td>November 1</td> </tr> </tbody> </table>' SET @Xpath = N'//tr' SELECT SQLHTTP.net.HtmlNodeCount(@Html, @Xpath) |
1 2 3 4 |
------ 5 |