Home > DeveloperSection > Forums > Extracting texts from html tags
jayprakash sharma
jayprakash sharma

Total Post:117

Posted on    September-20-2014 2:41 AM

 C# .NET  C# 

 1 Reply(s)
 922  View(s)
Rate this:

I have a page like this which has 3 values in li tags





public string mobilename1 = "";

public string mobilename2 = "";

public string mobilename3 = "";



    // Use this for initialization

    void Start () {


        HtmlWeb htmlweb = new HtmlWeb();

        HtmlAgilityPack.HtmlDocument doc = htmlweb.Load(openUrl);


    foreach (HtmlNode nd in doc.DocumentNode.SelectNodes("//li"))






How can I store all 3 values in those strings?

Anchal Kesharwani
Anchal Kesharwani

Total Post:10

Posted on    September-20-2014 2:58 AM

hi jayprakash,

We will easier to find 3 values in string array, for example:

List<string> mobilenames = new List<string>();


foreach (HtmlNode nd in doc.DocumentNode.SelectNodes("//li"))




InnerText is already a sting so no need to ToString() but get correct mobile names trim the spaces as Trim().

Don't want to miss updates? Please click the below button!

Follow MindStick