Solved

Extract text between two html tags

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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