Solved

Extract text between two html tags

Posted on 2013-02-06
2
477 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now