Quiero obtener cada row en .net son numero de una tabla de una base de datos pero me arroja esto, como podría evitar que salieran los <tr y td que solo me estableciera los numeros.
<tr><td>17788481</td></tr><tr><td>5955996</td></tr><tr><td>58585</td></tr>
mi vb.net
Dim client As New WebClient()
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)")
Dim baseurl As String = "http://dominio.com/Libreria/control/api/test1.php"
Dim data As Stream = client.OpenRead(baseurl)
Dim reader As New StreamReader(data)
Dim s As String = reader.ReadToEnd()
data.Close()
reader.Close()
s = s.Replace("<html><head></head><body><table CELLSPACING=10 class=tabla><tr><th>ALL</th><th>Testo</th></tr>", "").Replace("</table></body></html>", "").ToString()
RichTextBox1.Text = s.ToString()
Mi php
if ($result->num_rows > 0) {
echo "<html><head></head><body><table CELLSPACING=10 class=tabla><tr><th>ALL</th><th>Testo</th></tr>";
while($row = $result->fetch_assoc()) {
$descriptip = Encrypter::decrypt($row['numbers']);
echo "<tr><td>".$descriptip."</td></tr>";
}
echo "</table></body></html>";
} else {
echo "No se encuentran ningún usuario con numero de la suerte";
}
Cita de: SrTrp en 12 Agosto 2017, 23:44 PMcomo podría evitar que salieran los <tr y td que solo me estableciera los numeros.
Hola.
Lee:
- HtmlElement.InnerText Property | MSDN (https://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement.innertext(v=vs.110).aspx?)
Un ejemplo que podrías adaptar a tus necesidades:
Dim html As XElement =
<html>
<body>
<table>
<tr>
<th>Column</th>
</tr>
<tr>
<td>17788481</td>
<td>5955996</td>
<td>58585</td>
</tr>
</table>
</body>
</html>
Using wb As New WebBrowser
wb.ScriptErrorsSuppressed = True
wb.DocumentText = ""
wb.Document.OpenNew(replaceInHistory:=True)
wb.Document.Write(html.ToString())
Dim elements As HtmlElementCollection = wb.Document.GetElementsByTagName("TD")
For Each el As HtmlElement In elements
Debug.WriteLine(el.InnerText)
Next
End Using
PD: Para parsear documentos HTML en .NET, conviene utilizar la librería de terceros (y gratuita)
HtmlAgilityPack.
Saludos