---
title: "Extracting texts from html tags"  
description: "Extracting texts from html tags"  
author: "Anonymous User"  
published: 2014-09-20  
updated: 2014-09-20  
canonical: https://www.mindstick.com/forum/2263/extracting-texts-from-html-tags  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 1 minute  

---

# Extracting texts from html tags

I have a [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) like this which has 3 [values](https://www.mindstick.com/forum/327/sum-textbox-values) in li [tags](https://www.mindstick.com/interview/33868/difference-between-html-elements-and-tags)

```
<li>Samsung</li><li>Nokia</li><li>Sony</li> 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"))        {            mobilenames=nd.InnerText.ToString();         }
```

How can I [store](https://www.mindstick.com/articles/13125/tips-to-increase-sales-of-your-woocommerce-store) all 3 values in those [strings](https://www.mindstick.com/forum/161912/explain-the-python-strings)?

## Replies

### Reply by Anchal Kesharwani

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")){    mobilenames.Add(nd.InnerText.Trim());
```

**InnerText** is already a sting so no need to **ToString()** but get correct mobile names trim the spaces as **Trim()**.


---

Original Source: https://www.mindstick.com/forum/2263/extracting-texts-from-html-tags

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
