By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

How to read data from html file using vb6.0

chandru8
100+
P: 145
Hi to all

Can any one explain me to read data from an html file.
iam have written the code to read an html file using file system object,
but it reading the source code.

thanks to all
May 26 '08 #1
Share this Question
Share on Google+
10 Replies


kadghar
Expert 100+
P: 1,295
Hi to all

Can any one explain me to read data from an html file.
iam have written the code to read an html file using file system object,
but it reading the source code.

thanks to all
just open it as a text file, it depends on the version, but OPEN/FOR/AS would be of help in older ones. (vba or vb6 for example)
May 26 '08 #2

chandru8
100+
P: 145
thnks for your reply can give any example

my code reading with tags
May 27 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Yes, When you open any HTML file, it does read with all the Tags..
You need to parse the String and remove tags and get appropriate info..
You have to code for it..

Regards
Veena
May 27 '08 #4

!NoItAll
100+
P: 296
You do realize that you are not "reading data" but doing something called "screen scraping" instead.
HTML is a "display structure" not a "data structure." XML is a data structure. For example XML can tell you that the information between two tags is a monetary value, where HTML can tell you that it is only bold and blue. People tend to leave data structures alone, but display structures will change whimsically.
Ok - that said people still do what you are trying to do all the time.
Look at the Instr function in VB. Since HTML is not case sensitive make sure you make your Instr search case insensitive.

Des
May 27 '08 #5

chandru8
100+
P: 145
thanks kadghar for your reply
So can we use xml to read data from html,is it possible and how perfect it will be ,can you explain me little more in detail.
May 28 '08 #6

jeffstl
Expert 100+
P: 432
thanks kadghar for your reply
So can we use xml to read data from html,is it possible and how perfect it will be ,can you explain me little more in detail.
XML is not used as a programming language (cannot be used to "read" something). XML is strictly a transfer\storage syntax. In other words it really is a portable database file. Nothing more. It holds data, and describes it.

If you want to read a HTML file as text you need to use the VB6.0 FIle System Object and then use the string selection functions in VB to extract the specifics you want.
May 28 '08 #7

kadghar
Expert 100+
P: 1,295
thanks kadghar for your reply
So can we use xml to read data from html,is it possible and how perfect it will be ,can you explain me little more in detail.
well, sure, it wont be that easy, but it can be done,

for example
lets say you have a Table, i dont remember the exact tags, but lets asume <Table> </Table> start and close the table, that <row></row> start and close a row, and <col></col> start and ends a column, and your data is written like:
<table>
<row><col>a1</col><col>a2</col></row>
<row><col>b1</col><col>b2</col></row>
<row><col>c1</col><col>c2</col></row>
</table>

so it looks like:

a1 a2
b1 b2
c1 c2

if your HTML code is in a string (lets say Str1)
then INSTR(str1,"<table>") will return a Long, with the starting possition (lets call it Dou1)
INSTR(Dou1, Str1, "</table>") will give us the ending possition (say Dou2)
using MID from Dou1 to Dou2 will give you the code for where your data is.
using SPLIT a couple of times will put this data into an array (actually an array of arrays, but its not big deal)

HTH

Kad

Note: i forgot, i think split only works with characters as delimiters, so you might have to use REPLACE to change the tags with some delimiter of your choice.
May 29 '08 #8

100+
P: 123
oh..reading source code..that what I was looking for?

could you post your code for my reference?

thanks.

Hi to all

Can any one explain me to read data from an html file.
iam have written the code to read an html file using file system object,
but it reading the source code.

thanks to all
May 30 '08 #9

P: 1
Dear All,

I need your help to read and convert data from HTML files to MS SQL Server.
Data in HTML is stored in form of tables.

Someone please write a piece of code to open and Read tabular data in HTML.

Thanks
Jun 15 '09 #10

kadghar
Expert 100+
P: 1,295
i dont know many... i would use the one i wrote above (the one with INSTR), inside a DO/LOOP, writing the data into an array.

then put the array in an SQL Server Table.
Aug 4 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.