Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Extract text between two html tags

Posted on 2013-02-06
2
Medium Priority
?
493 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:
Meir Rivkin earned 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline

877 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