HTMLTag

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


Public

Tested

My Own Work
<%
Private Function HTMLTag(pathname, BetweenTag)
    dim FSO, objFile, a, tmp, firstCt, secondCt
    Set FSO                     = Server.CreateObject("Scripting.FileSystemObject")
    Set objFile             = FSO.OpenTextFile(pathname, 1, False)
    a                             = objFile.ReadAll()
    objFile.Close
    Set objFile             = Nothing
    Set FSO                     = Nothing
    Tag1                        = "<" & Ucase(BetweenTag) & ">"
    Tag2                        = ""
    firstCt                 = InStr(UCASE(a), Tag1) + Len(Tag1)
    secondCt                 = InStr(UCASE(a), Tag2)
    tmp                         = Mid( a, firstCt, secondCt - firstCt )
    Title                     = 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), "") + 7<br/>    secondCt = InStr(UCASE(a), "")
    tmp = Mid( a, firstCt, secondCt - firstCt )
    Title = CStr( Trim( tmp ) )
End Function
%>

pathname, BetweenTag

<% = Title(server.mappath("/file.htm"), "Title") %>

Views 294 Downloads 102

Classic ASP Texts + Strings
ANmarAmdeen
780
Attachments
Revisions

v1.0

Needs