ReadHTMLTag

Reads string between open and close HTML tag (between < ... > and < / ... >), pass the file name, and the tag (without < or This was originally a function called Title that reads the title of an HTML page

CodeFunctionName
What is this?

Public

Not Tested

Imported
<%
Function ReadHTMLTag(HTMLBlock, BetweenTag)
    Tag1 = " <" & UCase(BetweenTag)
    Tag2 = " </" & UCase(BetweenTag) & " >"
    firstCt = InStr(1, UCase(HTMLBlock), Tag1) + Len(Tag1)
    firstCt = InStr(firstCt, UCase(HTMLBlock), " >") + 1
    secondCt = InStr(UCase(HTMLBlock), Tag2)
    tmp = Mid(HTMLBlock, firstCt, secondCt - firstCt)
    ReadHTMLTag = CStr(Trim(tmp))
End Function


' ======================= Original function
' Example of calling Original function
' Title(server.mappath("/file.htm"))

' Original function was Title
Private Function Title(byVal pathname)
    dim objFSO, objFile, a, tmp, firstCt, secondCt
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(pathname, 1, False)
    a = objFile.ReadAll()
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    firstCt = InStr(UCASE(a), " <TITLE >") + 7
    secondCt = InStr(UCASE(a), " </TITLE >")
    tmp = Mid( a, firstCt, secondCt - firstCt )
    Title = CStr( Trim( tmp ) )
End Function
% >

pathname, BetweenTag

<% = ReadHTMLTag(FullHTMLBlock, "Title") %>

Views 1,028

Downloads 355

CodeID
DB ID

ANmarAmdeen
609
Attachments
Revisions

v6.0

Saturday
May
29
2021
Needs