{"id":164,"date":"2008-11-30T02:32:31","date_gmt":"2008-11-29T18:32:31","guid":{"rendered":""},"modified":"2014-02-27T22:57:28","modified_gmt":"2014-02-27T14:57:28","slug":"asp%e7%9a%84xml%e7%bc%93%e5%ad%98%e7%b1%bb%e4%bb%a3%e6%9b%bf%e4%ba%86application-2","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2008\/11\/30\/164.htm","title":{"rendered":"ASP\u7684XML\u7f13\u5b58\u7c7b,\u4ee3\u66ff\u4e86Application"},"content":{"rendered":"<p>&lt;% <br \/>\n&#8216;========================================= <br \/>\n&#8216; ClassName: RyM_ClsCache <br \/>\n&#8216; Version: 1.0 <br \/>\n&#8216; Date: 2006-8-2 <br \/>\n&#8216; Author: \u7f51\u6d77\u306e\u6c42\u751f <br \/>\n&#8216;========================================= <br \/>\n&#8216; \u8c03\u7528\u8bf4\u660e: <br \/>\n&#8216; Set CC = New RyM_ClsCache &#8216;\u521b\u5efa\u5bf9\u8c61 <br \/>\n&#8216; CC.CreateXmlObj &quot;Temp.xml&quot;,&quot;\/ROYAH_CACHE&quot; <br \/>\n&#8216; CC.Name = &quot;CA&quot; &#8216;\u8bbe\u7f6e\u7f13\u5b58\u540d <br \/>\n&#8216; If CC.IsXmlObj() Then &#8216;\u5982\u679c\u5b58\u5728\u7f13\u5b58\u5219 <br \/>\n&#8216; Temp = CC.Value &#8216;\u76f4\u63a5xml\u4e2d\u8bfb\u53d6\u503c <br \/>\n&#8216; Else \u5426\u5219 <br \/>\n&#8216; Temp = &quot;\u8981\u7f13\u5b58\u7684\u5185\u5bb9\uff0c\u53ea\u80fd\u662f\u5b57\u7b26\u4e32&quot; <br \/>\n&#8216; CC.Value = Temp &#8216;\u628a\u8981\u7f13\u5b58\u7684\u503c\u5199\u5165xml <br \/>\n&#8216; End If <br \/>\n&#8216; Set CC = Nothing &#8216;\u91ca\u653e\u5bf9\u8c61 <br \/>\n&#8216; \u53d8\u91cfTemp\u5c31\u662f\u7ecf\u8fc7\u7f13\u5b58\u540e\u7684\u5b57\u7b26\u4e32\u503c\u4e86 <br \/>\n&#8216;========================================= <br \/>\nClass RyM_ClsCache <br \/>\nPublic Reloadtime <br \/>\nPrivate XmlDom, XmlDoc, XmlNode, XmlAttr, AttrTime <br \/>\nPrivate CacheName, LocalCacheName, XmlPath <br \/>\nPrivate Sub Class_Initialize() <br \/>\nReloadtime = 14400 <br \/>\nEnd Sub <br \/>\nPrivate Sub Class_Terminate() <br \/>\nClose() <br \/>\nEnd Sub <br \/>\n&#8216;\u65b0\u5efa\u6587\u672c\u6587\u4ef6 <br \/>\nPrivate Function SaveToFile(ByVal strBody,ByVal SavePath) <br \/>\nSet ObjStream = Server.CreateObject(&quot;ADODB.Stream&quot;) <br \/>\nObjStream.Open <br \/>\nObjStream.Type = 2 <br \/>\nObjStream.Charset = &quot;GB2312&quot; <br \/>\nObjStream.WriteText strBody <br \/>\nObjStream.SaveToFile SavePath,2 <br \/>\nObjStream.Close <br \/>\nSet ObjStream = Nothing <br \/>\nEnd Function <br \/>\n&#8216;\u521b\u5efaXml\u5bf9\u8c61 <br \/>\nPublic Sub CreateXmlObj(ByVal XmlName, ByVal ChName) <br \/>\nSet XmlDom = Server.CreateObject(&quot;Microsoft.FreeThreadedXMLDOM&quot;) <br \/>\nXmlPath = Server.MapPath(XmlName) <br \/>\nCacheName = ChName <br \/>\nIf Not XmlDom.Load(XmlPath) Then &#8216;\u5982\u679c\u6307\u5b9a\u7684\u7f13\u5b58\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u81ea\u52a8\u65b0\u5efa <br \/>\nSaveToFile &quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;GB2312&quot;&quot;?&gt;&lt;ROYAH_CACHE&gt;&lt;\/ROYAH_CACHE&gt;&quot;,XmlPath <br \/>\nXmlDom.Load(XmlPath) <br \/>\nEnd If <br \/>\nEnd Sub <br \/>\n&#8216;\u8bbe\u7f6e\u8fd4\u56de\u6570\u636e\u8282\u70b9\u540d <br \/>\nPublic Property Let Name(ByVal vNewValue) <br \/>\nLocalCacheName = vNewValue <br \/>\nIf LocalCacheName &lt;&gt; &quot;&quot; Then <br \/>\nSet XmlDoc = XmlDom.documentElement.selectSingleNode(CacheName &amp; &quot;\/&quot; &amp; LocalCacheName) <br \/>\nEnd If <br \/>\nEnd Property <br \/>\n&#8216;\u8bbe\u7f6e\u5f53\u524d\u8282\u70b9\u503c <br \/>\nPublic Property Let Value(ByVal vNewValue) <br \/>\nIf (XmlDoc Is Nothing) Then <br \/>\nSet XmlDoc = XmlDom.documentElement.selectSingleNode(CacheName) <br \/>\nSet XmlNode = XmlDom.createElement(LocalCacheName) <br \/>\nSet XmlAttr = XmlDom.createAttribute(&quot;Time&quot;) <br \/>\nXmlNode.Text = vNewValue <br \/>\nXmlAttr.Text = Now() <br \/>\nXmlDoc.AppendChild(XmlNode) <br \/>\nXmlNode.setAttributeNode XmlAttr <br \/>\nXmlDom.Save(XmlPath) <br \/>\nElse <br \/>\nXmlDoc.Text = vNewValue <br \/>\nSet AttrTime = XmlDoc.selectSingleNode(&quot;.\/@Time&quot;) <br \/>\nAttrTime.Text = Now() <br \/>\nXmlDom.Save(XmlPath) <br \/>\nEnd If <br \/>\nEnd Property <br \/>\n&#8216;\u8fd4\u56de\u5f53\u524d\u8282\u70b9\u503c <br \/>\nPublic Property Get Value() <br \/>\nIf Not (XmlDoc Is Nothing) Then <br \/>\nValue = XmlDoc.Text <br \/>\nEnd If <br \/>\nEnd Property <br \/>\n&#8216;\u79fb\u9664\u5f53\u524d\u8282\u70b9 <br \/>\nPublic Sub Remove() <br \/>\nIf Not (XmlDoc Is Nothing) Then <br \/>\nXmlDoc.ParentNode.RemoveChild(XmlDoc) <br \/>\nXmlDom.Save(XmlPath) <br \/>\nEnd If <br \/>\nEnd Sub <br \/>\n&#8216;\u68c0\u6d4b\u5f53\u524d\u8282\u70b9\u662f\u5426\u5b58\u5728 <br \/>\nPublic Function IsXmlObj() <br \/>\nIsXmlObj = False <br \/>\nIf Not (XmlDoc Is Nothing) Then <br \/>\nIsXmlObj = True <br \/>\nSet AttrTime = XmlDoc.selectSingleNode(&quot;.\/@Time&quot;) <br \/>\nIf DateDiff(&quot;s&quot;,CDate(AttrTime.Text),Now()) &gt; (60*Reloadtime) Then IsXmlObj = False <br \/>\nEnd If <br \/>\nEnd Function <br \/>\n&#8216;\u91ca\u653e\u5168\u90e8\u5bf9\u8c61 <br \/>\nPublic Sub Close() <br \/>\nIf IsObject(XmlDom) Then Set XmlDom = Nothing <br \/>\nIf IsObject(XmlDoc) Then Set XmlDoc = Nothing <br \/>\nIf IsObject(XmlNode) Then Set XmlNode = Nothing <br \/>\nIf IsObject(XmlAttr) Then Set XmlAttr = Nothing <br \/>\nIf IsObject(AttrTime) Then Set XmlAttr = Nothing <br \/>\nEnd Sub <br \/>\nEnd Class <br \/>\n%&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;% &#8216;========================================= &#8216; ClassName: RyM_ClsCache &#8216; Version: 1.0 &#8216; Date&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-164","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=164"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":66019,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/164\/revisions\/66019"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=164"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}