Automatically generate static HTM using ASP + XML

xiaoxiao2021-03-06  51

I spent two hours, I made a small example. Function: Receive Table Single Lead Values ​​Generate Temporary XML files, combined with XSL, generate static HTML files.

<% author = request.form ("n_author") title = request.form ("n_title") content = request.form ("n_content") TEMPXML = Replace (Replace (now, ",", ",", ",", ",", ",,",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Objrootset Objroot = ObjDom.createElement ("Moonpiazza") objdom.Appendchild Objroot

Set objpi = objDom.createProcessinginstructionTRUction ("XML", "Version = '1.0') ObjDom.Insertbefore Objpi, objDom.childNodes (0)

Dim objBookset Objbook = objDom.createElement ("book") ObjRoot.Appendchild Objbook

Set objtit = objDom.createElement ("book name" Objtit.text = titleObjbook.appendchild objtit

Set objaut = objDom.createElement ("author" objaut.text = authorobjbook.appendchild Objaut

Set objpri = objDom.createElement ("Pricing") ObjPri.Text = ContentObjbook.Appendchild ObjPri

'Generate temporary XML is placed under TEMP folder

Objdom.save (Server.MAppath ("Temp /" & Tempxml)

'// The following section is generating HTM section chtmlfile = replace (Replace (now, ":", ",", "," "),", "") & ".htm"

CXMLFILE = Server.mappath ("Temp /" & Tempxml) cxslfile = server.mappath ("book.xsl") coutputfile = server.mappath ("news /" & chtmlfile)

Set oxml = server.createObject ("Microsoft.xmLDom") oxml.async = falseoxml.load (cxmlfile)

Set oXSL = Server.CreateObject ( "Microsoft.XMLDOM") oXSL.async = falseoXSL.load (cXSLFile) Set oOutput = Server.CreateObject ( "Microsoft.XMLDOM") Call oXML.transformNodeToObject (oXSL, oOutput)

Ooutput.save (coutputfile)

Set oxml = NothingSet oxsl = Nothingset Ooutput = Nothing

SQL = "INSERT INTO News (Author, Title, Content, URL) Values ​​('" & author & ",'" & title & ", '" & content & ",' news /" & chtmlfile & ")"

CONN.EXECUTE (SQL)

'Generate HTM files to the news folder

Response.Redirect ("news /" & chtmlfile)

%>

File list ->

<% response.contenttype = "text / html"%> <% response.write ("

") set = Server.createObject ("AdoDb.Recordset") RS.Open "Select * from news", conn, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, ("
"& rs (" title ") &" ") rs.movenextLoopResponse.write (" ")%>

转载请注明原文地址:https://www.9cbs.com/read-116442.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.041, SQL: 9