Solved

How can I read .html file in ASP.NET?

Posted on 2011-03-17
7
309 Views
Last Modified: 2012-05-11
Hello experts,

I run a debating club.  An external windows app software pushes out debate results in a table in a .html file.

Is there a way that I can read this table so that I can place the values of each field in a database?

I have attached a pic of the .html table. Table in HTML file
Thank you

Vince
0
Comment
Question by:vstack
7 Comments
 
LVL 4

Expert Comment

by:LeDaouk
ID: 35155418
familiar with vb.net?
0
 
LVL 4

Accepted Solution

by:
LeDaouk earned 250 total points
ID: 35155442
the code attached get the html tags to the string str
then you can manage it using mid(,,) function seraching for the html tag of each row
Dim web As New System.Net.WebClient()
            Dim url As String
            Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes("")
            Dim res As Byte()
            Dim str As String

url = "http://www.blablabla.com"
                res = web.UploadData(url, "POST", d)
                str = System.Text.Encoding.ASCII.GetString(res)

Open in new window

0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 250 total points
ID: 35155661
Hi, use this code

Add main namespace for this operation

using System.IO;

Read html file


string file = Server.MapPath ("abc.html");
StreamReader sr;
FileInfo fi = new FileInfo(file);
string input = "<pre>";
if(File.Exists(file))
{
     sr = File.OpenText(file);
     input += Server.HtmlEncode(sr.ReadToEnd());
     sr.Close();
}
input += "</pre>";
Label1.Text = input;

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vstack
ID: 35155923
Thanks, I will try the solutions and let you know.

I appreciate your efforts
0
 
LVL 4

Expert Comment

by:LeDaouk
ID: 35155932
welcome
0
 

Expert Comment

by:jayul
ID: 35163086
You have do it easily by using seprate tag <COL NAME>
0
 

Author Closing Comment

by:vstack
ID: 35164158
Thanks both solutions meet my needs.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 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