Dears,
Я хотел бы отображать только информацию title = или alt = в представлении DataGrid.
Если я ввожу те же самые тексты в теги td, все работает нормально. К сожалению, я не знаю, как выбрать, чтобы получить только информацию из заголовка и alt
Ниже моего кода в vb:
Public Class Class1
Public Function Test1() As DataTable
Dim Document As New HtmlAgilityPack.HtmlDocument()
Document.Load("\Desktop\test2.htm")
Dim table As HtmlAgilityPack.HtmlNode = Document.DocumentNode.SelectSingleNode("//table[@border='0']//tbody")
Dim datatab As New DataTable()
Dim rows = table.SelectNodes("tr")
For row As Integer = 0 To rows.Count - 1
If row = 0 Then
Dim cols = rows(row).SelectNodes("td")
dt.Columns.Add(New DataColumn(cols(0).InnerText.ToString()))
dt.Columns.Add(New DataColumn(cols(1).InnerText.ToString()))
dt.Columns.Add(New DataColumn(cols(2).InnerText.ToString()))
Else
Dim cols = rows(row).SelectNodes("td")
Dim dr As DataRow = datatab.NewRow()
dr(0) = cols(0).InnerText.ToString()
dr(1) = cols(1).InnerText.ToString()
dr(2) = cols(2).InnerText.ToString()
datatab.Rows.Add(dr)
End If
Next
Return datatab
End Function
End Class
Это код HTML
<!DOCTYPE html>
<head>
<title></title>
</head>
<body>
<table bordercolor="#808080" cellpadding="2" border="0">
<tbody>
<tr class="line">
<td algin="center">Headers one</td>
<td algin="center">Headers 2</td>
<td algin="center">Headers 3</td>
</tr>
<tr class="line">
<td align="center"><a href="http://page1"><img title="info:green:10.249.50.11" border="0" alt="info:green:10.249.50.11" src="red%20%20Xymon%20-%20Status%20@%20Thu%20Jan%2003%20172037%202019_pliki/green.gif" width="16" height="16"></a></td>
<td algin="center"><a href="http://pagew"><img title="disk:red:13h12m" border="0" alt="disk:red:13h12m" src="red%20%20Xymon%20-%20Status%20@%20Thu%20Jan%2003%20172037%202019_pliki/red-recent.gif" width="16" height="16"></a></td>
<td align="center"><a href="http://page5"><img title="disk:red:13h12m" border="0" alt="disk:red:13h12m" src="red%20%20Xymon%20-%20Status%20@%20Thu%20Jan%2003%20172037%202019_pliki/red-recent.gif" width="16" height="16"></a></td>
</tr>
<tr class="line">
<td align="center"><a href="http://page19"><img title="memory:yellow:13h02m" border="0" alt="memory:yellow:13h02m" src="red%20%20Xymon%20-%20Status%20@%20Thu%20Jan%2003%20172037%202019_pliki/yellow-recent.gif" width="16" height="16"></a></td>
<td align="center"><a href="http://page17"><img title="unibackup:red:24d05h19m" border="0" alt="unibackup:red:24d05h19m" src="red%20%20Xymon%20-%20Status%20@%20Thu%20Jan%2003%20172037%202019_pliki/red.gif" width="16" height="16"></a></td>
<td align="center"><a href="http://pasge34"><img title="disk:red:13h12m" border="0" alt="disk:red:13h12m" src="red%20%20Xymon%20-%20Status%20@%20Thu%20Jan%2003%20172037%202019_pliki/red-recent.gif" width="16" height="16"></a></td>
</tr>
</table>
</tbody>
</body>
</html>