Solved

Extract text between two html tags

Posted on 2013-02-06
2
474 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
Comment Utility
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
Comment Utility
thx
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Separate a number and letter from a string 25 23
Chat Room 1 24
Unable  to create new object 9 19
XML & .net 5 14
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

10 Experts available now in Live!

Get 1:1 Help Now