I master HtmlAgilityPack. I'm trying to get data from a pre-loaded page. Namely: There is a page 1.htm. I want to get the value from the table opposite the line "Operating system". (the document itself is attached). I do this:
private void simpleButton1_Click(object sender, EventArgs e)
{
// Создаю экземпляр класса
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
// Загружаю файл
doc.Load(@"D:\(тут путь к файлу)\1.htm");
// Пытаюсь получить информацию из ноды, но получаю null
HtmlAgilityPack.HtmlNode bodyNode = doc.DocumentNode.SelectSingleNode("//TD[@CLASS=pt]");
...
In general, it is necessary to extract a lot of information from the file, but I think that if one line is obtained, then further by analogy.
The required line was as follows:
private void simpleButton1_Click(object sender, EventArgs e)
{
// Создаю экземпляр класса
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
// Загружаю файл
doc.Load(@"D:\(тут путь к файлу)\1.htm");
foreach (HtmlAgilityPack.HtmlNode node in doc.DocumentNode.SelectNodes("//body/table[2]/tr[8]/td[4]"))
{
string stroka = node.InnerText;
}
But this option is "on the forehead." If you do not change the structure of my document. And how it is possible with the help of the search has not figured out yet.
foreach
? c? Also, I only have rough guesses what your comments could mean ... something about an "example class"? Could you translate these please?