HTML document tool-VBForums
Results 1 to 3 of 3

Thread: HTML document tool

  1. #1

    Thread Starter
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    HTML document tool

    Hello!

    No api calls today, but pure vb6. This tool "parses" html tags, then display them in a frame, you can edit their values one by one in a textbox. It also got some funky feature, you may find useful if you have to work with html documents.

    Undercommented, not-so-well organized, but works just like it should. And its pure vb ^^

    Ive done it in a couple of hours, but it was just 'nuff But, i'm still thinking on some better ways to do parsing html.

    Anyway, have fun!



    Note:
    If you want to use this method in your code, to process html documents, you can simply replace the text1.selstart property, to a private or public variable, that is just used to store the string pointer.
    Attached Files Attached Files
    Last edited by Jim Davis; Nov 30th, 2008 at 03:40 PM. Reason: update 1

  2. #2
    Hyperactive Member
    Join Date
    Feb 2008
    Posts
    327

    Re: HTML document tool

    just what i was looking for..great work..Jim Davis..let me check this one out..

  3. #3

    Thread Starter
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: HTML document tool

    You can use the algorithm of the Forward button, that will walk thru on each tags. But, it will skip <script> and <style> tags! That means, a <script src=".."> will not be replaced. Its better to replace the code that does the skip, also comment out the <style> things.

    For example, this will look for all <!-- --> tags and skip their content. These are the standards that used inside the <script and <style tags, to comment out the content, but the content will be interpreted by the browser, just wont show them.

    vb Code:
    1. 'in Private Sub cmdForward_Click() ...
    2. If InStr(1, LCase(Mid$(sHTMLDocument, Text1.SelStart, lSelLength)), "<!--", vbTextCompare) > 0 Then
    3.     lNewIndex = InStr(Text1.SelStart + lSelLength - 4, LCase(sHTMLDocument), "-->", vbTextCompare) + 3:
    4.     If lNewIndex < (Text1.SelStart + lSelLength - 4) Then lNewIndex = 0
    5.     GoTo ReCheck
    6. End If
    7.  
    8. '  If InStr(1, LCase(Mid$(sHTMLDocument, Text1.SelStart, lSelLength)), "<style ", vbTextCompare) > 0 Or _
    9. '    InStr(1, LCase(Mid$(sHTMLDocument, Text1.SelStart, lSelLength)), "<style>", vbTextCompare) > 0 Then
    10. '    lNewIndex = InStr(Text1.SelStart + lSelLength - 9, LCase(sHTMLDocument), "</style>", vbTextCompare) + 9: GoTo ReCheck
    11. '  End If

    After this modification, you can use the algo to walk thru the tags, that there you can execute the replacement for each src (cmdAuto2) and href (cmdAuto3) properties.
    You can also try to combine the algos of cmdAuto2 and cmdAuto3.
    Last edited by Jim Davis; Nov 26th, 2008 at 01:12 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.