How to read data from html file using vb6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandru8
    New Member
    • Sep 2007
    • 145

    How to read data from html file using vb6.0

    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
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by chandru8
    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)

    Comment

    • chandru8
      New Member
      • Sep 2007
      • 145

      #3
      thnks for your reply can give any example

      my code reading with tags

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        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

        Comment

        • !NoItAll
          Contributor
          • May 2006
          • 297

          #5
          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

          Comment

          • chandru8
            New Member
            • Sep 2007
            • 145

            #6
            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.

            Comment

            • jeffstl
              Recognized Expert Contributor
              • Feb 2008
              • 432

              #7
              Originally posted by chandru8
              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\storag e 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.

              Comment

              • kadghar
                Recognized Expert Top Contributor
                • Apr 2007
                • 1302

                #8
                Originally posted by chandru8
                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,"<ta ble>") 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.
                Last edited by kadghar; May 29 '08, 10:28 PM. Reason: add note

                Comment

                • perhapscwk
                  New Member
                  • Sep 2007
                  • 123

                  #9
                  oh..reading source code..that what I was looking for?

                  could you post your code for my reference?

                  thanks.

                  Originally posted by chandru8
                  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

                  Comment

                  • mehars
                    New Member
                    • Jun 2009
                    • 1

                    #10
                    Reading Tabular data from HTML

                    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

                    Comment

                    • kadghar
                      Recognized Expert Top Contributor
                      • Apr 2007
                      • 1302

                      #11
                      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.

                      Comment

                      Working...