Solved

Extract number from html tag

Posted on 2013-02-06
2
398 Views
Last Modified: 2013-02-06
Hi

I have the following html:

<span class='LocalTime' gmt_time='1360039849'></span>

Open in new window


How can I extract just the number, "1360039849" from this tag using c#?

Thanks
0
Comment
Question by:zattz
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38859236
if you have the html as text then u can do:

 string anchor = "gmt_time='";
            int startIndex = html.IndexOf(anchor) + anchor.Length;
            int endIndex = html.IndexOf('\'', startIndex);
            string gmt_time = html.Substring(startIndex, endIndex - startIndex );

Open in new window

0
 

Author Closing Comment

by:zattz
ID: 38859775
thx
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Code enhancement 4 22
How to use spatial data types in SQL Server Database project 2 24
Amazon S3 Images with .Net 3 15
C# Linq Select From List 3 18
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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.

820 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