Following is the HTML i am working on; (C# project)
</TR>
<TR>
`<TD ALIGN="center"> <INPUT TYPE="checkbox" **NAME**="f0" **VALUE**="14652 4-76-17-7-2024-R" ONCLICK=uncheck("f0")> </TD>
<TD> </TD>
<TD>76/07-17</TD>
<TD>14652</TD>
<TD> </TD>
<TD>9.3</TD>
<TD> 78 </TD>
<TD> </TD>
<TD> </TH>
</TR>
I can get the tr[td] inner values via a loop.
But in the same loop I can not access the “input” attributes (Name / Value) to extract values as a array to maintain data integrity.
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
foreach (var row in doc.DocumentNode.SelectNodes("//tr[td]")) //textBox5.Text
{
table.Rows.Add(row.SelectNodes("td").Select(td => td.InnerText).ToArray());
string namee1 = row.InnerText;
//These works but without the attribute details.
string Code_num = row.SelectSingleNode("//td//input").Attributes["value"].Value;
// this gives only the first value without looping.
MessageBox.Show(namee);
}
Code_num – gives me the first value only without looping through the document.
Attributes dose not pick and I only get null reference. I am not that familiar with linq. Prefer help from xpath if possible.
Appreciate your help!!! Thank in Advance
Fazlan Fawmy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.