Click here to Skip to main content
15,849,996 members
Home / Discussions / C#
   

C#

 
QuestionIs there a way to Convert binding dataMember? Pin
Geanny Martin24-Oct-23 3:50
Geanny Martin24-Oct-23 3:50 
AnswerRe: Is there a way to Convert binding dataMember? Pin
Alan N24-Oct-23 5:21
Alan N24-Oct-23 5:21 
NewsEvergrowth.AspForMarkDigExtension is out there now... Pin
James McCullough19-Oct-23 16:25
professionalJames McCullough19-Oct-23 16:25 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
OriginalGriff19-Oct-23 19:22
mveOriginalGriff19-Oct-23 19:22 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
James McCullough19-Oct-23 19:42
professionalJames McCullough19-Oct-23 19:42 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
OriginalGriff19-Oct-23 21:39
mveOriginalGriff19-Oct-23 21:39 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
jschell20-Oct-23 12:28
jschell20-Oct-23 12:28 
QuestionC# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown19-Oct-23 0:11
Tridip Bhattacharjee from Unknown19-Oct-23 0:11 
I want to parse multiple html table using htmlagility pack. i want to iterate in all TD and extract values.

please have a look at this url https://www.sec.gov/Archives/edgar/data/1108134/000110813423000018/bhlb-20230630.htm

the above url has many tabular data whose html tables i have to parse.

here i am pasting a small snippet of html table. please check how data is stored in this table.


HTML
<pre><table style="border-collapse:collapse;display:inline-table;margin-bottom:5pt;vertical-align:text-bottom;width:99.853%"> <tbody> <tr> <td style="width:1.0%"></td> <td style="width:71.960%"></td> <td style="width:0.1%"></td> <td style="width:0.1%"></td> <td style="width:0.532%"></td> <td style="width:0.1%"></td> <td style="width:1.0%"></td> <td style="width:11.637%"></td> <td style="width:0.1%"></td> <td style="width:0.1%"></td> <td style="width:0.532%"></td> <td style="width:0.1%"></td> <td style="width:1.0%"></td> <td style="width:11.639%"></td> <td style="width:0.1%"></td> </tr> <tr style="height:12pt"> <td colspan="3" style="padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:1pt;font-weight:700;line-height:100%"> </span></td> <td colspan="3" style="padding:0 1pt"></td> <td colspan="3" rowspan="2" style="padding:2px 1pt;text-align:center;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:8pt;font-weight:700;line-height:100%">June 30,<br>2023</span></td> <td colspan="3" style="padding:0 1pt"></td> <td colspan="3" rowspan="2" style="padding:2px 1pt;text-align:center;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:8pt;font-weight:700;line-height:100%">December 31,<br>2022</span></td> </tr> <tr style="height:12pt"> <td colspan="3" style="padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:8pt;font-weight:700;line-height:100%">(In thousands, except share data)</span></td> <td colspan="3" style="padding:0 1pt"></td> <td colspan="3" style="padding:0 1pt"></td> </tr> <tr> <td colspan="3" style="background-color:#cceeff;border-top:1pt solid #000000;padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:700;line-height:100%">Assets</span></td> <td colspan="3" style="background-color:#cceeff;padding:0 1pt"></td> <td colspan="3" style="background-color:#cceeff;border-top:1pt solid #000000;padding:2px 1pt;text-align:right;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:1pt;font-weight:700;line-height:100%"> </span></td> <td colspan="3" style="background-color:#cceeff;padding:0 1pt"></td> <td colspan="3" style="background-color:#cceeff;border-top:1pt solid #000000;padding:2px 1pt;text-align:right;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:1pt;font-weight:400;line-height:100%"> </span></td> </tr> <tr> <td colspan="3" style="background-color:#ffffff;padding:2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%">Cash and due from banks</span></td> <td colspan="3" style="background-color:#ffffff;padding:0 1pt"></td> <td style="background-color:#ffffff;padding:2px 0 2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%">$</span></td> <td style="background-color:#ffffff;padding:2px 0;text-align:right;vertical-align:bottom"> <span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%"> <ix:nonfraction unitref="usd" contextref="c-3" decimals="-3" name="us-gaap:CashAndDueFromBanks" format="ixt:num-dot-decimal" scale="3" id="f-32">120,285</ix:nonfraction>   </span> </td> <td style="background-color:#ffffff;padding:2px 1pt 2px 0;text-align:right;vertical-align:bottom"></td> <td colspan="3" style="background-color:#ffffff;padding:0 1pt"></td> <td style="background-color:#ffffff;padding:2px 0 2px 1pt;text-align:left;vertical-align:bottom"><span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%">$</span></td> <td style="background-color:#ffffff;padding:2px 0;text-align:right;vertical-align:bottom"> <span style="color:#000000;font-family:'Times New Roman',sans-serif;font-size:10pt;font-weight:400;line-height:100%"> <ix:nonfraction unitref="usd" contextref="c-4" decimals="-3" name="us-gaap:CashAndDueFromBanks" format="ixt:num-dot-decimal" scale="3" id="f-33">145,342</ix:nonfraction>   </span> </td> <td style="background-color:#ffffff;padding:2px 1pt 2px 0;text-align:right;vertical-align:bottom"></td> </tr> </tbody> </table> 



Some time TD has direct data and some time TD has SPAN which has data. some time SPAN has custom tag which has data <ix:nonfraction

for a long time i am trying to loop through all TD's of all table and extract data only but getting no success.

here is my code which is trying to iterate and get data but code is not working.


C#
<pre>var table1 = htmlDoc.DocumentNode.SelectNodes("//table");
            var tbody = table1.ChildNodes["tbody"];
            var lst = new List<Table1>();
            foreach (var row in tbody.ChildNodes.Where(r => r.Name == "tr"))
            {
                var tbl1 = new Table1();
                var columnsArray = row.ChildNodes.Where(c => c.Name == "td").ToArray();
                for (int i = 0; i < columnsArray.Length; i++)
                {
                    if (i == 0)
                        tbl1.Course = columnsArray[i].InnerText.Trim();
                    if (i == 1)
                        tbl1.Count = columnsArray[i].InnerText.Trim();
                    if (i == 2)
                        tbl1.Correct = columnsArray[i].InnerText.Trim();
                }
                lst.Add(tbl1);
            }


Please some one guide me with a sample code which can extract data from html table TR,TD

please please need your support and help to extract data from html tables. thanks

AnswerRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Richard MacCutchan19-Oct-23 5:11
mveRichard MacCutchan19-Oct-23 5:11 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Dave Kreskowiak19-Oct-23 6:19
mveDave Kreskowiak19-Oct-23 6:19 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Richard MacCutchan19-Oct-23 6:24
mveRichard MacCutchan19-Oct-23 6:24 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown26-Oct-23 11:47
Tridip Bhattacharjee from Unknown26-Oct-23 11:47 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Richard MacCutchan26-Oct-23 23:04
mveRichard MacCutchan26-Oct-23 23:04 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown27-Oct-23 4:36
Tridip Bhattacharjee from Unknown27-Oct-23 4:36 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Richard MacCutchan27-Oct-23 4:50
mveRichard MacCutchan27-Oct-23 4:50 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown2-Nov-23 3:49
Tridip Bhattacharjee from Unknown2-Nov-23 3:49 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Dave Kreskowiak2-Nov-23 5:09
mveDave Kreskowiak2-Nov-23 5:09 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Pete O'Hanlon2-Nov-23 4:45
subeditorPete O'Hanlon2-Nov-23 4:45 
AnswerRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
jschell19-Oct-23 6:08
jschell19-Oct-23 6:08 
GeneralRe: C# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown26-Oct-23 11:45
Tridip Bhattacharjee from Unknown26-Oct-23 11:45 
Questionmysql db in cloud with c# desktop application geting too slow Pin
Member 1103383418-Oct-23 7:35
Member 1103383418-Oct-23 7:35 
AnswerRe: mysql db in cloud with c# desktop application geting too slow Pin
jeron118-Oct-23 8:25
jeron118-Oct-23 8:25 
AnswerRe: mysql db in cloud with c# desktop application geting too slow Pin
Dave Kreskowiak18-Oct-23 9:38
mveDave Kreskowiak18-Oct-23 9:38 
AnswerRe: mysql db in cloud with c# desktop application geting too slow Pin
jschell19-Oct-23 6:11
jschell19-Oct-23 6:11 
QuestionNeed to create next button Pin
Member 1611639316-Oct-23 5:26
Member 1611639316-Oct-23 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.