Link to home
Start Free TrialLog in
Avatar of acorp
acorp

asked on

find 'n extract (dealing with HTML)

this is the problem
<META name="Author" content="Jim Smith">
how to find exactly this tag and extract the value of 'content' in a variable
i.e. name="Jim Smith"
     metatag="Author"
Avatar of zivf
zivf

what is the problem? extracting text out from the net? searching the file? searching a string inside a string?
please try to be more specific, it seems quite solvable to me.
consider the above 'answer' as a comment.
sorry.
acorp, please reject this 'answer' so i can post a proper solution to you.
Just so i get a messag!

Avatar of acorp

ASKER

ok
the tag must be found in a web page (*.htm,*.html...)
that is loaded withing the program (not from the net, the file is found on the hard drive)
i think i am specific enogh in the question, just try to get it

ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of acorp

ASKER

i can't get this to work
can you make a working sample project of this
if you do i will pay 150 points

Hi here is an example of my call to the function. - i'd forgotten #1 on my line input
Below it is the text file I used as a test
you need a command button on your form to give the click event.
Any questions please let me know.

Private Sub Command1_Click()

   'EXAMPLE OF A CALL TO THE FUNCTION
   Dim sStr1 As String
   Dim sres1 As String
   Dim sYourTag1 As String
   
   sYourTag1 = "content"
   Open "A:H.HTM" For Input As #1
    While Not EOF(1) And sres1 = ""
      Line Input #1, sStr1
      sres1 = find_text(sStr1, sYourTag1)
    Wend
       
    Close #1
   
    MsgBox sres1

End Sub

TEST DATA in a:h.htm (text format file)

<dummy test line>
<META name="Author" content="Jim Smith">
test dATA


Jim Smith should be displayed in the message box.




Avatar of acorp

ASKER

az i promised, your 150 points
thanks for the source, it worked great now
Avatar of acorp

ASKER

OOOPS
there is a problem
sorry
if i have two tags like this
<META name="Author" content="Jim Smith">
<META name="Email" content="jim@smith.net">
how to make one variable with 'Jim Smith' and another with 'jim@smith.net'
sorry to be late for this, just got out of my mind
'hope this amendment is what you want.

Private Sub Command1_Click()

         'EXAMPLE OF A CALL TO THE FUNCTION
         'I have redesigned this so that each
         'setting is retrieved e.g. for content
         'first setting is in scodes(1) , second in scodes(2)
         
         
         Dim sStr1 As String
         Dim sres1 As String
         Dim sYourTag1 As String
         Dim sCodes(5) As String    'increase this if need more
         Dim icount As Integer
         Dim c
         
         sYourTag1 = "content"
         Open "A:H.HTM" For Input As #1
          While Not EOF(1)
            Line Input #1, sStr1
            sres1 = find_text(sStr1, sYourTag1)
            If sres1 <> "" Then
           
                icount = icount + 1
                sCodes(icount) = sres1
               
            End If
          Wend
             
          Close #1
           
        For c = 1 To icount
          MsgBox "setting " + CStr(c) + " = " + sCodes(c)
        Next

End Sub

Avatar of acorp

ASKER

yes, but if the tags are in that order
<META name="Email" content="jim@smith.net">
<META name="Author" content="Jim Smith">
not in that:
<META name="Author" content="Jim Smith">
<META name="Email" content="jim@smith.net">
(first the email tag then the author tag i mean)
i wouldn't know which value is for author and which for email
you know what
i will pay you another 200 pionts if you make me a visual basic project
5 text fields (author, email, title, words, description)
on load fill these 5 fields with appropriate values from a text file
when i modify these fields i need to save them back in the file without messing up the other things in it (don't write the common dialog procedure)just explain how to replace the modified tags
the file looks like that
---------------
<dummy test line>
<META name="Author" content="Jim Smith">
<META name="Email" content="Jimmy@jimmi.com">
<META name="Title" content="Yahoo">
<META name="Words" content="these are words">
<META name="Description" content="this is description">
test dATA
----------------
this is it
my email is webmaster@dome.communitech.net

P.S. the program is a Meta tag generator, i need my users to be able to open an HTML file and te values in the tags to be loaded in the fields, then i need to save back that HTML file and the modifications to be in it without having multiple linesin the code of the page

P.S. remember , the project is for another 200 or 400 points (however you want) even 600, 800 or 1000 is possbile
if you have ICQ contact me 3395581
Hi

As promised I've got that ready now.  I've done some testing and it seems to meet your requirements.  Perhaps you could post a question marked for my attention in this section then I could post the code there for you. Is this ok?  I think 200 points is a fair enough reward for my work on this.

Deighton
Avatar of acorp

ASKER

ok
i will post in a second
thanks for everything