SoFunction
Updated on 2025-03-02

Packaging website files using XML under asp


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit %>
<% On Error Resume Next %>
<% ="UTF-8" %>
<% =99999999 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Packaging Program_Me_www.</title>
</head>

<body>
<%
Dim ZipPathDir,ZipPathFile
Dim startime,endtime
'Change the path to the folder to be packaged here
ZipPathDir = "D:\testasp\dictionary\xmlPacked\scrollColor"'
ZipPathFile = ""
if right(ZipPathDir,1)<>"\" then ZipPathDir=ZipPathDir&"\"
'Start packing
CreateXml(ZipPathFile)
'Travel through all files and folders in the directory
sub LoadData(DirPath)
    dim XmlDoc
dim fso            'fso object
dim objFolder      'Folder Object
dim objSubFolders 'Subfolder collection
dim objSubFolder   'Subfolder object
dim objFiles       'File Collection
dim objFile        'File Object
    dim objStream
    dim pathname,TextStream,pp,Xfolder,Xfpath,Xfile,Xpath,Xstream
    dim PathNameStr
    ("=========="&DirPath&"==========<br>")
    set fso=("")
set objFolder=(DirPath)'Create folder object

     DirPath
    

    Set XmlDoc = ("")
     (ZipPathFile)
    =false

'Write to each folder path
    set Xfolder = ("//root").AppendChild(("folder"))
    Set Xfpath = (("path"))
         = replace(DirPath,ZipPathDir,"")
        set objFiles=
            for each objFile in objFiles
                if lcase(DirPath & ) <> lcase(("PATH_TRANSLATED")) then
                     "---<br/>"
                    PathNameStr = DirPath & "" & 
                     PathNameStr & ""
                    
                    '================================================
'The path and file contents of the write file
                   set Xfile = ("//root").AppendChild(("file"))
                   Set Xpath = (("path"))
                        = replace(PathNameStr,ZipPathDir,"")
'Create a file stream to read the file content and write it to the XML file
                   Set objStream = ("")
                    = 1
                   ()
                   (PathNameStr)
                    = 0

                   Set Xstream = (("stream"))
                        "xmlns:dt","urn:schemas-microsoft-com:datatypes"
'The file content is stored in two-system
                        = "bin.base64"
                        = ()

                   set objStream=nothing
                   set Xpath = nothing
                   set Xstream = nothing
                   set Xfile = nothing
                  '================================================
                end if
            next
     "<p>"
    ((ZipPathFile))
    set Xfpath = nothing
    set Xfolder = nothing
    set XmlDoc = nothing

'Created subfolder object
    set objSubFolders=
'Call recursively traverse subfolders
        for each objSubFolder in objSubFolders
            pathname = DirPath &  & "\"
            LoadData(pathname)
        next
    set objFolder=nothing
    set objSubFolders=nothing
    set fso=nothing

end sub

'Create an empty XML file to prepare for writing to the file
sub CreateXml(FilePath)
'The program starts execution time
    startime=timer()
    dim XmlDoc,Root
    Set XmlDoc = ("")
         = False
        Set Root = ("xml","version='1.0' encoding='UTF-8'")
        (Root)
        (("root"))
        ((FilePath))
        Set Root = Nothing
    Set XmlDoc = Nothing
    LoadData(ZipPathDir)
'Program end time
    endtime=timer()
("Page execution time:" & FormatNumber((endtime-startime),3) & "seconds")
end sub
%>
</body>
</html>