Medo Medo
Medo Medo

Reputation: 1018

c# HtmlAgilityPack read non html tags

am trying to read MYOWNTAG using HtmlAgilityPack but I get Object reference not set to an instance of an objec
how can I print the name ahmed
this is my c# code

 string html = "<p>HELLO <MYOWNTAG> ahmed </MYOWNTAG> again</p>";

        HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
        doc.LoadHtml(html);
        foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//MYOWNTAG"))
                MessageBox.Show(node.InnerText);

Upvotes: 2

Views: 683

Answers (1)

Vyacheslav Yudanov
Vyacheslav Yudanov

Reputation: 451

string html = "<p>HELLO <MYOWNTAG> ahmed </MYOWNTAG> again</p>";

    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
    doc.LoadHtml(html);
    foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//myowntag"))
            MessageBox.Show(node.InnerText);

It works. HtmlAgilityPack did ToLower() for all tags.

Upvotes: 2

Related Questions