Solved

Extract text between two html tags

Posted on 2013-02-06
2
479 Views
Last Modified: 2013-02-06
hi all,

can somebody help me extract the text between two html tags in c#?

string inboxSubjectStartTag = "<span style=\"white-space: pre;\">";
string inboxinboxSubjectEndTag = "</span>";

Open in new window


The full html is

<span style="white-space: pre;">Re:hey</span>

Open in new window


I just want "Re:hey" extracted.

Thank you
0
Comment
Question by:zattz
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38859245
if you have the html as text then u can do:
 string anchor = "<span style=\"white-space: pre;\">";
            int startIndex = html.IndexOf(anchor) + anchor.Length;
            int endIndex = html.IndexOf('<', startIndex);
            string txt = html.Substring(startIndex, endIndex - startIndex );

Open in new window

0
 

Author Closing Comment

by:zattz
ID: 38859778
thx
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question