rental model
The rental model version is designed for single-threaded access. To use the rental model control, use the "Microsoft.DOMDocument" progID.
free-threaded model
The free-threaded version is designed for multiple thread access. To use the free-threaded control, use the "Microsoft.FreeThreadedDOMDocument" progID.
If you plan for several threads to access your XML data from a single control, be sure to use the free-threaded control. If only one thread will access the XML data, use the rental model control for better performance.
The following is a sample global.asa file that creates session-level and application-level free-threaded versions of the XML control.
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
ON error RESUME next
SET Application("AppFXMLdoc") = _
server.CreateObject("MSXML2.FreeThreadedDOMDocument")
SET Session("SessFXMLdoc") = _
server.CreateObject("MSXML2.FreeThreadedDOMDocument")
End Sub
Sub Session_OnEnd
ON error RESUME next
SET Session("SessFXMLdoc") = nothing
SET Application("AppFXMLdoc") = nothing
Session("SessFXMLdoc") = empty
Application("AppFXMLdoc") = empty
End Sub
</SCRIPT>
Scripts accessing the Session and Application objects will be able to simultaneously access the "AppFXMLdoc" and "SessFXMLdoc" objects.
<%
strSourceFile = Server.MapPath("/") & "\List.xml"
"获取XML文件的路径这里根据你的虚拟目录不同而不同
Set objXML = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
"以自由线程创建一个XML对像
objXML.load(strSourceFile)"把XML文件读入内存
Set objRootsite = objXML.documentElement.selectSingleNode("NewList")
"选取NewList节点
%>
六、建立写新留言程序(PostNew.asp)
"根据得到的数据建立XML片段
set objXML2=Server.CreateObject("Microsoft.XMLDOM")
"建立一个新XML对像
objXML2.loadXML(XMLnode)
"把XML版片段读入内存中
set rootNewNode=objXML2.documentElement
"获得objXML2的根节点
objRootlist.appendChild(rootNewNode)
"把XML片段插入到List.xml中
objXML.save(strSourceFile)
"存储lsit.xml文件(因为不存储List.xml只在内存中更新了)
set objXML=nothing
set objXML2=nothing
response.write "谢谢您的留言"
response.end