I have a html table like below, received from company url,
Now I have been using .IndexOf() and .SubString2(), no complain.
But after reading,
and understanding that my logic will fail if the table,th or td are not proper.
So I tried using MiniHtmlParser, but am unable to wrap my head on it. I search the Forum but did not find any similar one. Also read "B4X-Pleroma-master" codes, still could not make it.
Below is my code,
But I am unable to get all th values and then respective td values per row.
I want to extract,
and then
Any guide on it is appreciated.
Regards,
Anand
B4X:
<body>
<table>
<tr>
<th> name</th>
<th>age</th>
<th>sex</th>
</tr>
<tr>
<td>Jack</td>
<td>16</td>
<td>M</td>
</tr>
<tr>
<td>Jill</td>
<td>15</td>
<td>F</td>
</tr>
</table>
</body>
Now I have been using .IndexOf() and .SubString2(), no complain.
But after reading,
Read HTML between elements (text)
Hi everyone :rolleyes: I used Google translate.... I need a library for read html. Html code: Test text I need a code read html top and save "Text text" for string b4a
www.b4x.com
So I tried using MiniHtmlParser, but am unable to wrap my head on it. I search the Forum but did not find any similar one. Also read "B4X-Pleroma-master" codes, still could not make it.
Below is my code,
B4X:
Dim html As String = $"
<body>
<table>
<tr>
<th> name</th>
<th>age</th>
<th>sex</th>
</tr>
<tr>
<td>Jack</td>
<td>16</td>
<td>M</td>
</tr>
<tr>
<td>Jill</td>
<td>15</td>
<td>F</td>
</tr>
</table>
</body>"$
Dim parser As MiniHtmlParser
parser.Initialize
Dim root As HtmlNode = parser.Parse(html)
Dim p As HtmlNode = parser.FindNode(root, "table", Null)
Log(parser.GetTextFromNode(p, 0))
Dim p1 As HtmlNode = parser.FindNode(p, "th", Null)
Log(parser.GetTextFromNode(p1, 0))
Dim p1 As HtmlNode = parser.FindNode(p, "th", Null)
Log(parser.GetTextFromNode(p1, 0))
But I am unable to get all th values and then respective td values per row.
I want to extract,
name,age,sex
and then
Jack,16,M
Jill,15,F
Any guide on it is appreciated.
Regards,
Anand