469,073 Members | 1,817 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,073 developers. It's quick & easy.

How to read data from html file using vb6.0

chandru8
145 100+
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
10 13157
kadghar
1,295 Expert 1GB
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
145 100+
thnks for your reply can give any example

my code reading with tags
May 27 '08 #3
QVeen72
1,445 Expert 1GB
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
296 100+
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
145 100+
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
432 Expert 256MB
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
1,295 Expert 1GB
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
perhapscwk
123 100+
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
mehars
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
1,295 Expert 1GB
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.

Similar topics

2 posts views Thread by Gunnar | last post: by
2 posts views Thread by Reply Via Newsgroup | last post: by
18 posts views Thread by jas | last post: by
1 post views Thread by Magix | last post: by
10 posts views Thread by Tibby | last post: by
6 posts views Thread by Karthik | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.