| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> asp >> asp chu li xml shu ju de fa song 、 jie shou lei

asp chu li xml shu ju de fa song 、 jie shou lei

2008-08-05 07:05:04 编辑來源:互联网 评论
 
 
 
本文为【asp处理xml数据的发送、接收类】的拼音翻译版
  ben asp lei ke yi yong lai chu li xml bao de fa song yu jie shou 。 ke yong yu ge zhong yi gou xi tong zhi jian API jie kou jian tong xun , yi ji chu li Web Service de tiao yong yu jie shou 。
  shu xing :
  URL : fa song xml de jie shou di zhi
  String
  zhi xie
  Message : xi tong cuo wu xin xi
  String
  zhi du
  XmlNode: huo qu fa song bao XML zhong jie dian de zhi
  String
  zhi du
  shen shu :Str: jie dian ming cheng
  GetXmlData: huo qu fan hui XML shu ju dui xiang
  XMLDom
  zhi du
  fang fa :
  LoadXmlFromFile : cong wai bu xml wen jian tian chong XmlDoc dui xiang
  shen shu Path:xml lu jing
  Void
  LoadXmlFromString : yong zi fu chuan tian chong XmlDoc dui xiang
  shen shu Str:xml zi fu chuan
  Void
  NodeValue she zhi node de shen shu
  shen shu
  NodeName jie dian ming
  NodeText zhi
  NodeType bao cun lei xing [text=0,cdata=1]
  blnEncode shi fou bian ma [true,false]
  Void
  SendHttpData : fa song xml bao
  PrintSendXmlData : da yin fa song qing qiu XML shu ju
  PrintGetXmlData : da yin fan hui XML shu ju
  SaveSendXmlDataToFile : bao cun fa song qing qiu xml shu ju dao wen jian , wen jian ming wei sendxml_ ri qi .txt
  SaveGetXmlDataToFile : bao cun fan hui XML shu ju dao wen jian , wen jian ming wei getxml_ ri qi .txt
  GetSingleNode : huo qu fan hui xml de jie dian xin xi
  shen shu Nodestring: jie dian ming
  AcceptHttpData : jie shou XML bao , cuo wu xin xi tong guo Message dui xiang huo qu
  AcceptSingleNode: fan hui jie shou XML bao jie dian xin xi
  shen shu Nodestring: jie dian ming
  PrintAcceptXmlData : da yin jie shou duan jie shou dao de XML shu ju
  SaveAcceptXmlDataToFile : bao cun jie shou de XML bao shu ju dao wen jian , wen jian ming wei acceptxml_ ri qi .txt
  SaveDebugStringToFile : bao cun tiao shi shu ju dao wen jian , wen jian ming wei debugnote_ ri qi .txt
  shen shu Debugstr: tiao shi xin xi
  
  dai ma :
  xmlcls.asp
  <%
  Rem chu li xml shu ju de fa song 、 jie shou lei
  '--------------------------------------------------
  ' zhuan zai de shi hou qing bao liu ban quan xin xi
  ' zuo zhe :walkman
  ' gong si : bu bu wei ying ke ji you xian ze ren gong si
  ' wang zhi :http://www.shouji138.com
  ' ban ben :ver1.0
  '--------------------------------------------------
  Class XmlClass
  Rem bian liang ding yi
  Private XmlDoc,XmlHttp
  Private MessageCode,SysKey,XmlPath
  Private m_GetXmlDoc,m_url
  Private m_XmlDocAccept
  Rem chu shi hua
  Private Sub Class_Initialize()
   On Error Resume Next
   MessageCode = ""
   XmlPath = ""
   Set XmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0")
   XmlDoc.ASYNC = False
  End Sub
  Rem xiao hui dui xiang
  Private Sub Class_Terminate()
   If IsObject(XmlDoc) Then Set XmlDoc = Nothing
   If IsObject(m_XmlDocAccept) Then Set m_XmlDocAccept = Nothing
   If IsObject(m_GetXmlDoc) Then Set m_GetXmlDoc = Nothing
  End Sub
  ' gong gong shu xing ding yi kai shi --------------------------
  Rem cuo wu xin xi
  Public Property Get Message()
   Message = MessageCode
  End Property
  Rem fa song xml de di zhi
  Public Property Let URL(str)
   m_url = str
  End Property
  ' gong gong shu xing ding yi jie shu --------------------------
  ' si you guo cheng 、 fang fa kai shi --------------------------
  Rem jia zai xml
  Private Sub LoadXmlData()
   If XmlPath <> "" Then
   If Not XmlDoc.Load(XmlPath) Then
   XmlDoc.LoadXml "<?xml version=""1.0"" encoding=""gb2312""?><root/>"
   End If
   Else
   XmlDoc.LoadXml "<?xml version=""1.0"" encoding=""gb2312""?><root/>"
   End If
  End Sub
  Rem zi fu zhuan hua
  Private Function AnsiToUnicode(ByVal str)
   Dim i, j, c, i1, i2, u, fs, f, p
   AnsiToUnicode = ""
   p = ""
   For i = 1 To Len(str)
   c = Mid(str, i, 1)
   j = AscW(c)
   If j < 0 Then
   j = j + 65536
   End If
   If j >= 0 And j <= 128 Then
   If p = "c" Then
   AnsiToUnicode = " " & AnsiToUnicode
   p = "e"
   End If
   AnsiToUnicode = AnsiToUnicode & c
   Else
   If p = "e" Then
   AnsiToUnicode = AnsiToUnicode & " "
   p = "c"
   End If
   AnsiToUnicode = AnsiToUnicode & ("&#" & j & ";")
   End If
   Next
  End Function
  Rem zi fu zhuan hua
  Private Function strAnsi2Unicode(asContents)
   Dim len1,i,varchar,varasc
   strAnsi2Unicode = ""
   len1=LenB(asContents)
   If len1=0 Then Exit Function
   For i=1 to len1
   varchar=MidB(asContents,i,1)
   varasc=AscB(varchar)
   If varasc > 127 Then
   If MidB(asContents,i+1,1)<>"" Then
   strAnsi2Unicode = strAnsi2Unicode & chr(ascw(midb(asContents,i+1,1) & varchar))
   End If
   i=i+1
   Else
   strAnsi2Unicode = strAnsi2Unicode & Chr(varasc)
   End If
   Next
  End Function
  Rem wang wen jian zhong zhui jia zi fu
  Private Sub WriteStringToFile(filename,str)
   On Error Resume Next
   Dim fs,ts
   Set fs= createobject("script_ing.filesystemobject")
   If Not IsObject(fs) Then Exit Sub
   Set ts=fs.OpenTextFile(Server.MapPath(filename),8,True)
   ts.writeline(str)
   ts.close
   Set ts=Nothing
   Set fs=Nothing
  End Sub
  ' si you guo cheng 、 fang fa jie shu --------------------------
  ' gong gong fang fa kai shi --------------------------
  ''''''''''' fa song xml bu fen kai shi
  Rem cong wai bu xml wen jian tian chong XmlDoc dui xiang
  Public Sub LoadXmlFromFile(path)
   XmlPath = Server.MapPath(path)
   LoadXmlData()
  End Sub
  Rem yong zi fu chuan tian chong XmlDoc dui xiang
  Public Sub LoadXmlFromString(str)
   XmlDoc.LoadXml str
  End Sub
  Rem she zhi node de shen shu ru NodeValue "appID",AppID,1,False
  '--------------------------------------------------
  ' shen shu :
  'NodeName jie dian ming
  'NodeText zhi
  'NodeType bao cun lei xing [text=0,cdata=1]
  'blnEncode shi fou bian ma [true,false]
  '--------------------------------------------------
  Public Sub NodeValue(Byval NodeName,Byval NodeText,Byval NodeType ,Byval blnEncode)
   Dim ChildNode,CreateCDATASection
   NodeName = Lcase(NodeName)
   If XmlDoc.documentElement.selectSingleNode(NodeName) is nothing Then
   Set ChildNode = XmlDoc.documentElement.appendChild(XmlDoc.createNode(1,NodeName,""))
   Else
   Set ChildNode = XmlDoc.documentElement.selectSingleNode(NodeName)
   End If
   If blnEncode = True Then
   NodeText = AnsiToUnicode(NodeText)
   End If
   If NodeType = 1 Then
   ChildNode.Text = ""
   Set CreateCDATASection = XmlDoc.createCDATASection(Replace(NodeText,"]]>","]]&gt;"))
   ChildNode.appendChild(createCDATASection)
   Else
   ChildNode.Text = NodeText
   End If
  End Sub
  '--------------------------------------------------
  ' huo qu fa song bao XML zhong jie dian de zhi
  ' shen shu :
  'Str jie dian ming
  '--------------------------------------------------
  Public Property Get XmlNode(Byval Str)
   If XmlDoc.documentElement.selectSingleNode(Str) is Nothing Then
   XmlNode = "Null"
   Else
   XmlNode = XmlDoc.documentElement.selectSingleNode(Str).text
   End If
  End Property
  '--------------------------------------------------
  ' huo qu fan hui XML shu ju dui xiang
  ' li :
  ' dang GetXmlData bu wei NULL shi ,GetXmlData wei XML dui xiang
  '--------------------------------------------------
  Public Property Get GetXmlData()
   Set GetXmlData = m_GetXmlDoc
  End Property
  '--------------------------------------------------
  ' fa song xml bao http://www.devdao.com/
  '--------------------------------------------------
  Public Sub SendHttpData()
   Dim i,GetXmlDoc,LoadAppid
   Set Xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
   Set GetXmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0") ' fan hui xml bao
   XmlHttp.Open "POST", m_url, false
   XmlHttp.SetRequestHeader "content-type", "text/xml"
   XmlHttp.Send XmlDoc
   'Response.Write strAnsi2Unicode(xmlhttp.responseBody)
   If GetXmlDoc.load(XmlHttp.responseXML) Then
   Set m_GetXmlDoc = GetXmlDoc
   Else
   MessageCode = " qing qiu shu ju cuo wu !"
   Exit Sub
   End If
   Set GetXmlDoc = Nothing
   Set XmlHttp = Nothing
  End Sub
  '--------------------------------------------------
  ' da yin fa song qing qiu XML shu ju
  '--------------------------------------------------
  Public Sub PrintSendXmlData()
   Response.Clear
   Response.ContentType = "text/xml"
   Response.CharSet = "gb2312"
   Response.Expires = 0
   Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>"&vbNewLine
   Response.Write XmlDoc.documentElement.XML
  End Sub
  '--------------------------------------------------
  ' da yin fan hui XML shu ju
  '--------------------------------------------------
  Public Sub PrintGetXmlData()
   Response.Clear
   Response.ContentType = "text/xml"
   Response.CharSet = "gb2312"
   Response.Expires = 0
   If IsObject(m_GetXmlDoc) Then
   Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>"&vbNewLine
   Response.Write m_GetXmlDoc.documentElement.XML
   Else
   Response.Write "<?xml version=""1.0"" encoding=""gb2312""?><root></root>"
   End If
  End Sub
  Rem bao cun fa song qing qiu xml shu ju dao wen jian , wen jian ming wei sendxml_ ri qi .txt
  Public Sub SaveSendXmlDataToFile()
   Dim filename,str
   filename = "sendxml_" & DateValue(now) & ".txt"
   str = ""
   str = str & ""& Now() & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine
   str = str & XmlDoc.documentElement.XML & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   str = str & vbNewLine & vbNewLine & vbNewLine
   WriteStringToFile filename,str
  End Sub
  Rem bao cun fan hui XML shu ju dao wen jian , wen jian ming wei getxml_ ri qi .txt
  Public Sub SaveGetXmlDataToFile()
   Dim filename,str
   filename = "getxml_" & DateValue(now) & ".txt"
   str = ""
   str = str & ""& Now() & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   If IsObject(m_GetXmlDoc) Then
   str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine
   str = str & m_GetXmlDoc.documentElement.XML
   Else
   str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine & "<root>" & vbNewLine & "</root>"
   End If
   str = str & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   str = str & vbNewLine & vbNewLine & vbNewLine
   WriteStringToFile filename,str
  End Sub
  '--------------------------------------------------
  ' huo qu fan hui xml de jie dian xin xi
  'XmlClassObj.GetSingleNode("//msg")
  '--------------------------------------------------
  Public Function GetSingleNode(nodestring)
   If IsObject(m_GetXmlDoc) Then
   GetSingleNode = m_GetXmlDoc.documentElement.selectSingleNode(nodestring).text
   Else
   GetSingleNode = ""
   End If
  End Function
  '''''''''''''''''' fa song xml bu fen jie shu
  '''''''''''''''''' jie shou xml bu fen kai shi
  '--------------------------------------------------
  ' jie shou XML bao , cuo wu xin xi tong guo Message dui xiang huo qu
  '--------------------------------------------------
  Public Function AcceptHttpData()
   Dim XMLdom
   Set XMLdom = Server.CreateObject("Microsoft.XMLDOM")
   XMLdom.Async = False
   XMLdom.Load(Request)
   If XMLdom.parseError.errorCode <> 0 Then
   MessageCode = " bu neng zheng que jie shou shu ju " & "Descript_ion: " & XMLdom.parseError.reason & "<br>Line: " & XMLdom.parseError.Line
   Set m_XmlDocAccept = Null
   Else
   Set m_XmlDocAccept = XMLdom
   End If
  End Function
  '--------------------------------------------------
  ' fan hui jie shou XML bao jie dian xin xi
  'XmlClassObj.GetSingleNode("//msg")
  '--------------------------------------------------
  Public Function AcceptSingleNode(nodestring)
   If IsObject(m_XmlDocAccept) Then
   AcceptSingleNode = m_XmlDocAccept.documentElement.selectSingleNode(nodestring).text
   Else
   AcceptSingleNode = ""
   End If
  End Function
  '--------------------------------------------------
  ' da yin jie shou duan jie shou dao de XML shu ju
  '--------------------------------------------------
  Public Sub PrintAcceptXmlData()
   Response.Clear
   Response.ContentType = "text/xml"
   Response.CharSet = "gb2312"
   Response.Expires = 0
   If IsObject(m_XmlDocAccept) Then
   Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>"&vbNewLine
   Response.Write m_XmlDocAccept.documentElement.XML
   Else
   Response.Write "<?xml version=""1.0"" encoding=""gb2312""?><root></root>"
   End If
  End Sub
  Rem bao cun jie shou de XML bao shu ju dao wen jian , wen jian ming wei acceptxml_ ri qi .txt
  Public Sub SaveAcceptXmlDataToFile()
   Dim filename,str
   filename = "acceptxml_" & DateValue(now) & ".txt"
   str = ""
   str = str & ""& Now() & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   If IsObject(m_XmlDocAccept) Then
   str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine
   str = str & m_XmlDocAccept.documentElement.XML
   Else
   str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine & "<root>" & vbNewLine & "</root>"
   End If
   str = str & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   str = str & vbNewLine & vbNewLine & vbNewLine
   WriteStringToFile filename,str
  End Sub
  '''''''''''''''''' jie shou xml bu fen jie shu
  Rem bao cun tiao shi shu ju dao wen jian , wen jian ming wei debugnote_ ri qi .txt
  Public Sub SaveDebugStringToFile(debugstr)
   Dim filename,str
   filename = "debugnote_" & DateValue(now) & ".txt"
   str = ""
   str = str & ""& Now() & vbNewLine
   str = str & "---------------------------------------------"& vbNewLine
   str = str & debugstr & vbNewLine
   str = str & "---------------------------------------------"
   str = str & vbNewLine & vbNewLine & vbNewLine
   WriteStringToFile filename,str
  End Sub
  ' gong gong fang fa jie shu --------------------------
  End Class
  %>
  ce shi yong li :
  sendxml.asp
  <%
  Option Explicit
  Response.buffer = True
  Response.Expires=-1
  %>
  <!--#include file="xmlcls.asp"-->
  <%
  Const Apisysno = "23498927347234234987"
  Const ActionURL = "http://www.shouji138.com/aspnet2/acceptxml.asp" Rem xiang ying de wen jian xie url di zhi
  Dim XmlClassObj
  Set XmlClassObj = new XmlClass ' chuang jian dui xiang
  XmlClassObj.LoadXmlFromString("<?xml version=""1.0"" encoding=""gb2312""?><root/>") ' yong xml zi fu tian chong XMLDOC dui xiang , yong lai fa song xml
  XmlClassObj.URL = ActionURL ' she zhi xiang ying de url
  Rem xml ge shi
  Rem "<?xml version="1.0" encoding="gb2312"?>
  Rem <root>
  Rem <sysno></sysno>
  Rem <username></username>
  Rem <pwd></pwd>
  Rem <email></email>
  Rem <pagename></pagename>
  Rem <pageurl></pageurl>
  Rem </root>
  XmlClassObj.NodeValue "sysno",Apisysno,0,False
  XmlClassObj.NodeValue "username","testusername",0,False
  XmlClassObj.NodeValue "pwd","pwd",0,False
  XmlClassObj.NodeValue "email","web@shouji138.com",0,False
  XmlClassObj.NodeValue "pagename"," zhan dian ",0,False
  XmlClassObj.NodeValue "pageurl","http://www.shouji138.com",1,False
  XmlClassObj.SaveSendXmlDataToFile() ' jiang fa song de xml shu ju ku bao cun ru txt wen jian
  XmlClassObj.SendHttpData() ' kai shi fa song xml shu ju
  'XmlClassObj.PrintGetXmlData() ' da yin jie shou dao de xml shu ju
  'response.write XmlClassObj.Message ' da yin cuo wu xin xi
  XmlClassObj.SaveGetXmlDataToFile() ' jiang jie shou dao de xml shu ju ku cun ru txt wen jian
  response.write XmlClassObj.GetSingleNode("//message") ' xian shi shou dao de xml shu ju de msg jie dian de zhi
  Set XmlClassObj = Nothing ' xiao hui dui xiang shi li
  %>
  acceptxml.asp
  <%
  Rem Api yong hu zhu ce jie kou
  %>
  <%
  Response.Expires= -1
  Response.Addheader "pragma","no-cache"
  Response.AddHeader "cache-control","no-store"
  %>
  <!--#Include File="xmlcls.asp"-->
  <%
  Rem xml ge shi
  Rem "<?xml version="1.0" encoding="gb2312"?>
  Rem <root>
  Rem <sysno></sysno>
  Rem <username></username>
  Rem <pwd></pwd>
  Rem <email></email>
  Rem <pagename></pagename>
  Rem <pageurl></pageurl>
  Rem </root>
  Const Apisysno = "23498927347234234987"
  On Error Resume Next
  Dim XmlClassObj
  Set XmlClassObj = new XmlClass ' chuang jian dui xiang
  XmlClassObj.AcceptHttpData() ' jie shou xml shu ju
  XmlClassObj.SaveAcceptXmlDataToFile() ' jiang jie shou dao de xml shu ju cun ru txt wen jian
  Err.clear
  Dim message
  Dim sysno,username,pwd,email,PageName,PageURL
  sysno = XmlClassObj.AcceptSingleNode("//sysno")
  username = XmlClassObj.AcceptSingleNode("//username")
  pwd = XmlClassObj.AcceptSingleNode("//pwd")
  email = XmlClassObj.AcceptSingleNode("//email")
  PageName = XmlClassObj.AcceptSingleNode("//pagename")
  PageURL = XmlClassObj.AcceptSingleNode("//pageurl")
  XmlClassObj.SaveDebugStringToFile("sysno=" & sysno) ' cun ru debug ri zhi wen jian
  If Err Then
  message = message & Err.Descript_ion
  Else
  Err.clear
  If sysno <> Apisysno Then
   message = " qing wu fei fa shi yong !"
  Else
   message = regUser(username,pwd,email,PageName,PageURL)
  End If
  End If
  'XmlClassObj.SaveDebugStringToFile("message=" & message) ' jiang message zhi cun ru debug ri zhi wen jian
  Set XmlClassObj = Nothing ' xiao hui dui xiang shi li
  Response.ContentType = "text/xml" ' shu chu xml shu ju liu gei fa song duan
  Response.Charset = "gb2312"
  Response.Clear
  Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>" & vbnewline
  Response.Write "<root>" & vbnewline
  Response.Write "<message>" & message & "</message>" & vbnewline
  Response.Write "<nowtime>" & Now() & "</nowtime>" & vbnewline
  Response.Write "</root>" & vbnewline
  Function regUser(username,pwd,email,PageName,PageURL)
  '''''''''''''''''''
  ''''''''''''''''''
  '''''''''''''''''
  ' cao zuo shu ju ku zhu ce yong hu
  '''''''''''''''''
  ''''''''''''''
  regUser = "OK"
  End Function
  %>
  xia zai di zhi :http://www.shouji138.com/files/Xmlcls.rar
  yan shi di zhi :http://www.shouji138.com/aspnet2/sendxml.asp【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
ben asp lei ke yi yong lai chu li xml bao de fa song yu jie shou 。 ke yong yu ge zhong yi gou xi tong zhi jian API jie kou jian tong xun , yi ji chu li Web Service de tiao yong yu jie shou 。 shu xing : URL : fa song xml de jie shou di zhi String zhi xie Message : xi tong cuo wu xin xi String zhi du XmlNode: huo qu fa song bao XML zhong jie dian de zhi String zhi du shen shu :Str: jie dian ming cheng GetXmlData: huo qu fan hui XML shu ju dui xiang XMLDom zhi du fang fa : LoadXmlFromFile : cong wai bu xml wen jian tian chong XmlDoc dui xiang shen shu Path:xml lu jing Void LoadXmlFromString : yong zi fu chuan tian chong XmlDoc dui xiang shen shu Str:xml zi fu chuan Void NodeValue she zhi node de shen shu shen shu NodeName jie dian ming NodeText zhi NodeType bao cun lei xing [text=0,cdata=1] blnEncode shi fou bian ma [true,false] Void SendHttpData : fa song xml bao PrintSendXmlData : da yin fa song qing qiu XML shu ju PrintGetXmlData : da yin fan hui XML shu ju SaveSendXmlDataToFile : bao cun fa song qing qiu xml shu ju dao wen jian , wen jian ming wei sendxml_ ri qi .txt SaveGetXmlDataToFile : bao cun fan hui XML shu ju dao wen jian , wen jian ming wei getxml_ ri qi .txt GetSingleNode : huo qu fan hui xml de jie dian xin xi shen shu Nodestring: jie dian ming AcceptHttpData : jie shou XML bao , cuo wu xin xi tong guo Message dui xiang huo qu AcceptSingleNode: fan hui jie shou XML bao jie dian xin xi shen shu Nodestring: jie dian ming PrintAcceptXmlData : da yin jie shou duan jie shou dao de XML shu ju SaveAcceptXmlDataToFile : bao cun jie shou de XML bao shu ju dao wen jian , wen jian ming wei acceptxml_ ri qi .txt SaveDebugStringToFile : bao cun tiao shi shu ju dao wen jian , wen jian ming wei debugnote_ ri qi .txt shen shu Debugstr: tiao shi xin xi dai ma : xmlcls.asp <% Rem chu li xml shu ju de fa song 、 jie shou lei '-------------------------------------------------- ' zhuan zai de shi hou qing bao liu ban quan xin xi ' zuo zhe :walkman ' gong si : bu bu wei ying ke ji you xian ze ren gong si ' wang zhi :http://www.shouji138.com ' ban ben :ver1.0 '-------------------------------------------------- Class XmlClass Rem bian liang ding yi Private XmlDoc,XmlHttp Private MessageCode,SysKey,XmlPath Private m_GetXmlDoc,m_url Private m_XmlDocAccept Rem chu shi hua Private Sub Class_Initialize() On Error Resume Next MessageCode = "" XmlPath = "" Set XmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0") XmlDoc.ASYNC = False End Sub Rem xiao hui dui xiang Private Sub Class_Terminate() If IsObject(XmlDoc) Then Set XmlDoc = Nothing If IsObject(m_XmlDocAccept) Then Set m_XmlDocAccept = Nothing If IsObject(m_GetXmlDoc) Then Set m_GetXmlDoc = Nothing End Sub ' gong gong shu xing ding yi kai shi -------------------------- Rem cuo wu xin xi Public Property Get Message() Message = MessageCode End Property Rem fa song xml de di zhi Public Property Let URL(str) m_url = str End Property ' gong gong shu xing ding yi jie shu -------------------------- ' si you guo cheng 、 fang fa kai shi -------------------------- Rem jia zai xml Private Sub LoadXmlData() If XmlPath <> "" Then If Not XmlDoc.Load(XmlPath) Then XmlDoc.LoadXml "<?xml version=""1.0"" encoding=""gb2312""?><root/>" End If Else XmlDoc.LoadXml "<?xml version=""1.0"" encoding=""gb2312""?><root/>" End If End Sub Rem zi fu zhuan hua Private Function AnsiToUnicode(ByVal str) Dim i, j, c, i1, i2, u, fs, f, p AnsiToUnicode = "" p = "" For i = 1 To Len(str) c = Mid(str, i, 1) j = AscW(c) If j < 0 Then j = j + 65536 End If If j >= 0 And j <= 128 Then If p = "c" Then AnsiToUnicode = " " & AnsiToUnicode p = "e" End If AnsiToUnicode = AnsiToUnicode & c Else If p = "e" Then AnsiToUnicode = AnsiToUnicode & " " p = "c" End If AnsiToUnicode = AnsiToUnicode & ("&#" & j & ";") End If Next End Function Rem zi fu zhuan hua Private Function strAnsi2Unicode(asContents) Dim len1,i,varchar,varasc strAnsi2Unicode = "" len1=LenB(asContents) If len1=0 Then Exit Function For i=1 to len1 varchar=MidB(asContents,i,1) varasc=AscB(varchar) If varasc > 127 Then If MidB(asContents,i+1,1)<>"" Then strAnsi2Unicode = strAnsi2Unicode & chr(ascw(midb(asContents,i+1,1) & varchar)) End If i=i+1 Else strAnsi2Unicode = strAnsi2Unicode & Chr(varasc) End If Next End Function Rem wang wen jian zhong zhui jia zi fu Private Sub WriteStringToFile(filename,str) On Error Resume Next Dim fs,ts Set fs= createobject("script_ing.filesystemobject") If Not IsObject(fs) Then Exit Sub Set ts=fs.OpenTextFile(Server.MapPath(filename),8,True) ts.writeline(str) ts.close Set ts=Nothing Set fs=Nothing End Sub ' si you guo cheng 、 fang fa jie shu -------------------------- ' gong gong fang fa kai shi -------------------------- ''''''''''' fa song xml bu fen kai shi Rem cong wai bu xml wen jian tian chong XmlDoc dui xiang Public Sub LoadXmlFromFile(path) XmlPath = Server.MapPath(path) LoadXmlData() End Sub Rem yong zi fu chuan tian chong XmlDoc dui xiang Public Sub LoadXmlFromString(str) XmlDoc.LoadXml str End Sub Rem she zhi node de shen shu ru NodeValue "appID",AppID,1,False '-------------------------------------------------- ' shen shu : 'NodeName jie dian ming 'NodeText zhi 'NodeType bao cun lei xing [text=0,cdata=1] 'blnEncode shi fou bian ma [true,false] '-------------------------------------------------- Public Sub NodeValue(Byval NodeName,Byval NodeText,Byval NodeType ,Byval blnEncode) Dim ChildNode,CreateCDATASection NodeName = Lcase(NodeName) If XmlDoc.documentElement.selectSingleNode(NodeName) is nothing Then Set ChildNode = XmlDoc.documentElement.appendChild(XmlDoc.createNode(1,NodeName,"")) Else Set ChildNode = XmlDoc.documentElement.selectSingleNode(NodeName) End If If blnEncode = True Then NodeText = AnsiToUnicode(NodeText) End If If NodeType = 1 Then ChildNode.Text = "" Set CreateCDATASection = XmlDoc.createCDATASection(Replace(NodeText,"]]>","]]&gt;")) ChildNode.appendChild(createCDATASection) Else ChildNode.Text = NodeText End If End Sub '-------------------------------------------------- ' huo qu fa song bao XML zhong jie dian de zhi ' shen shu : 'Str jie dian ming '-------------------------------------------------- Public Property Get XmlNode(Byval Str) If XmlDoc.documentElement.selectSingleNode(Str) is Nothing Then XmlNode = "Null" Else XmlNode = XmlDoc.documentElement.selectSingleNode(Str).text End If End Property '-------------------------------------------------- ' huo qu fan hui XML shu ju dui xiang ' li : ' dang GetXmlData bu wei NULL shi ,GetXmlData wei XML dui xiang '-------------------------------------------------- Public Property Get GetXmlData() Set GetXmlData = m_GetXmlDoc End Property '-------------------------------------------------- ' fa song xml bao [url=http://www.devdao.com/]http://www.devdao.com/[/url] '-------------------------------------------------- Public Sub SendHttpData() Dim i,GetXmlDoc,LoadAppid Set Xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0") Set GetXmlDoc = Server.CreateObject("msxml2.FreeThreadedDOMDocument.3.0") ' fan hui xml bao XmlHttp.Open "POST", m_url, false XmlHttp.SetRequestHeader "content-type", "text/xml" XmlHttp.Send XmlDoc 'Response.Write strAnsi2Unicode(xmlhttp.responseBody) If GetXmlDoc.load(XmlHttp.responseXML) Then Set m_GetXmlDoc = GetXmlDoc Else MessageCode = " qing qiu shu ju cuo wu !" Exit Sub End If Set GetXmlDoc = Nothing Set XmlHttp = Nothing End Sub '-------------------------------------------------- ' da yin fa song qing qiu XML shu ju '-------------------------------------------------- Public Sub PrintSendXmlData() Response.Clear Response.ContentType = "text/xml" Response.CharSet = "gb2312" Response.Expires = 0 Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>"&vbNewLine Response.Write XmlDoc.documentElement.XML End Sub '-------------------------------------------------- ' da yin fan hui XML shu ju '-------------------------------------------------- Public Sub PrintGetXmlData() Response.Clear Response.ContentType = "text/xml" Response.CharSet = "gb2312" Response.Expires = 0 If IsObject(m_GetXmlDoc) Then Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>"&vbNewLine Response.Write m_GetXmlDoc.documentElement.XML Else Response.Write "<?xml version=""1.0"" encoding=""gb2312""?><root></root>" End If End Sub Rem bao cun fa song qing qiu xml shu ju dao wen jian , wen jian ming wei sendxml_ ri qi .txt Public Sub SaveSendXmlDataToFile() Dim filename,str filename = "sendxml_" & DateValue(now) & ".txt" str = "" str = str & ""& Now() & vbNewLine str = str & "---------------------------------------------"& vbNewLine str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine str = str & XmlDoc.documentElement.XML & vbNewLine str = str & "---------------------------------------------"& vbNewLine str = str & vbNewLine & vbNewLine & vbNewLine WriteStringToFile filename,str End Sub Rem bao cun fan hui XML shu ju dao wen jian , wen jian ming wei getxml_ ri qi .txt Public Sub SaveGetXmlDataToFile() Dim filename,str filename = "getxml_" & DateValue(now) & ".txt" str = "" str = str & ""& Now() & vbNewLine str = str & "---------------------------------------------"& vbNewLine If IsObject(m_GetXmlDoc) Then str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine str = str & m_GetXmlDoc.documentElement.XML Else str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine & "<root>" & vbNewLine & "</root>" End If str = str & vbNewLine str = str & "---------------------------------------------"& vbNewLine str = str & vbNewLine & vbNewLine & vbNewLine WriteStringToFile filename,str End Sub '-------------------------------------------------- ' huo qu fan hui xml de jie dian xin xi 'XmlClassObj.GetSingleNode("//msg") '-------------------------------------------------- Public Function GetSingleNode(nodestring) If IsObject(m_GetXmlDoc) Then GetSingleNode = m_GetXmlDoc.documentElement.selectSingleNode(nodestring).text Else GetSingleNode = "" End If End Function '''''''''''''''''' fa song xml bu fen jie shu '''''''''''''''''' jie shou xml bu fen kai shi '-------------------------------------------------- ' jie shou XML bao , cuo wu xin xi tong guo Message dui xiang huo qu '-------------------------------------------------- Public Function AcceptHttpData() Dim XMLdom Set XMLdom = Server.CreateObject("Microsoft.XMLDOM") XMLdom.Async = False XMLdom.Load(Request) If XMLdom.parseError.errorCode <> 0 Then MessageCode = " bu neng zheng que jie shou shu ju " & "Descript_ion: " & XMLdom.parseError.reason & "<br>Line: " & XMLdom.parseError.Line Set m_XmlDocAccept = Null Else Set m_XmlDocAccept = XMLdom End If End Function '-------------------------------------------------- ' fan hui jie shou XML bao jie dian xin xi 'XmlClassObj.GetSingleNode("//msg") '-------------------------------------------------- Public Function AcceptSingleNode(nodestring) If IsObject(m_XmlDocAccept) Then AcceptSingleNode = m_XmlDocAccept.documentElement.selectSingleNode(nodestring).text Else AcceptSingleNode = "" End If End Function '-------------------------------------------------- ' da yin jie shou duan jie shou dao de XML shu ju '-------------------------------------------------- Public Sub PrintAcceptXmlData() Response.Clear Response.ContentType = "text/xml" Response.CharSet = "gb2312" Response.Expires = 0 If IsObject(m_XmlDocAccept) Then Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>"&vbNewLine Response.Write m_XmlDocAccept.documentElement.XML Else Response.Write "<?xml version=""1.0"" encoding=""gb2312""?><root></root>" End If End Sub Rem bao cun jie shou de XML bao shu ju dao wen jian , wen jian ming wei acceptxml_ ri qi .txt Public Sub SaveAcceptXmlDataToFile() Dim filename,str filename = "acceptxml_" & DateValue(now) & ".txt" str = "" str = str & ""& Now() & vbNewLine str = str & "---------------------------------------------"& vbNewLine If IsObject(m_XmlDocAccept) Then str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine str = str & m_XmlDocAccept.documentElement.XML Else str = str & "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine & "<root>" & vbNewLine & "</root>" End If str = str & vbNewLine str = str & "---------------------------------------------"& vbNewLine str = str & vbNewLine & vbNewLine & vbNewLine WriteStringToFile filename,str End Sub '''''''''''''''''' jie shou xml bu fen jie shu Rem bao cun tiao shi shu ju dao wen jian , wen jian ming wei debugnote_ ri qi .txt Public Sub SaveDebugStringToFile(debugstr) Dim filename,str filename = "debugnote_" & DateValue(now) & ".txt" str = "" str = str & ""& Now() & vbNewLine str = str & "---------------------------------------------"& vbNewLine str = str & debugstr & vbNewLine str = str & "---------------------------------------------" str = str & vbNewLine & vbNewLine & vbNewLine WriteStringToFile filename,str End Sub ' gong gong fang fa jie shu -------------------------- End Class %> ce shi yong li : sendxml.asp <% Option Explicit Response.buffer = True Response.Expires=-1 %> <!--#include file="xmlcls.asp"--> <% Const Apisysno = "23498927347234234987" Const ActionURL = "[url=http://www.shouji138.com/aspnet2/acceptxml.asp]http://www.shouji138.com/aspnet2/acceptxml.asp[/url]" Rem xiang ying de wen jian xie url di zhi Dim XmlClassObj Set XmlClassObj = new XmlClass ' chuang jian dui xiang XmlClassObj.LoadXmlFromString("<?xml version=""1.0"" encoding=""gb2312""?><root/>") ' yong xml zi fu tian chong XMLDOC dui xiang , yong lai fa song xml XmlClassObj.URL = ActionURL ' she zhi xiang ying de url Rem xml ge shi Rem "<?xml version="1.0" encoding="gb2312"?> Rem <root> Rem <sysno></sysno> Rem <username></username> Rem <pwd></pwd> Rem <email></email> Rem <pagename></pagename> Rem <pageurl></pageurl> Rem </root> XmlClassObj.NodeValue "sysno",Apisysno,0,False XmlClassObj.NodeValue "username","testusername",0,False XmlClassObj.NodeValue "pwd","pwd",0,False XmlClassObj.NodeValue "email","[url=mailto:web@shouji138.com]web@shouji138.com",0,False[/url] XmlClassObj.NodeValue "pagename"," zhan dian ",0,False XmlClassObj.NodeValue "pageurl","[url=http://www.shouji138.com]http://www.shouji138.com",1,False[/url] XmlClassObj.SaveSendXmlDataToFile() ' jiang fa song de xml shu ju ku bao cun ru txt wen jian XmlClassObj.SendHttpData() ' kai shi fa song xml shu ju 'XmlClassObj.PrintGetXmlData() ' da yin jie shou dao de xml shu ju 'response.write XmlClassObj.Message ' da yin cuo wu xin xi XmlClassObj.SaveGetXmlDataToFile() ' jiang jie shou dao de xml shu ju ku cun ru txt wen jian response.write XmlClassObj.GetSingleNode("//message") ' xian shi shou dao de xml shu ju de msg jie dian de zhi Set XmlClassObj = Nothing ' xiao hui dui xiang shi li %> acceptxml.asp <% Rem Api yong hu zhu ce jie kou %> <% Response.Expires= -1 Response.Addheader "pragma","no-cache" Response.AddHeader "cache-control","no-store" %> <!--#Include File="xmlcls.asp"--> <% Rem xml ge shi Rem "<?xml version="1.0" encoding="gb2312"?> Rem <root> Rem <sysno></sysno> Rem <username></username> Rem <pwd></pwd> Rem <email></email> Rem <pagename></pagename> Rem <pageurl></pageurl> Rem </root> Const Apisysno = "23498927347234234987" On Error Resume Next Dim XmlClassObj Set XmlClassObj = new XmlClass ' chuang jian dui xiang XmlClassObj.AcceptHttpData() ' jie shou xml shu ju XmlClassObj.SaveAcceptXmlDataToFile() ' jiang jie shou dao de xml shu ju cun ru txt wen jian Err.clear Dim message Dim sysno,username,pwd,email,PageName,PageURL sysno = XmlClassObj.AcceptSingleNode("//sysno") username = XmlClassObj.AcceptSingleNode("//username") pwd = XmlClassObj.AcceptSingleNode("//pwd") email = XmlClassObj.AcceptSingleNode("//email") PageName = XmlClassObj.AcceptSingleNode("//pagename") PageURL = XmlClassObj.AcceptSingleNode("//pageurl") XmlClassObj.SaveDebugStringToFile("sysno=" & sysno) ' cun ru debug ri zhi wen jian If Err Then message = message & Err.Descript_ion Else Err.clear If sysno <> Apisysno Then message = " qing wu fei fa shi yong !" Else message = regUser(username,pwd,email,PageName,PageURL) End If End If 'XmlClassObj.SaveDebugStringToFile("message=" & message) ' jiang message zhi cun ru debug ri zhi wen jian Set XmlClassObj = Nothing ' xiao hui dui xiang shi li Response.ContentType = "text/xml" ' shu chu xml shu ju liu gei fa song duan Response.Charset = "gb2312" Response.Clear Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>" & vbnewline Response.Write "<root>" & vbnewline Response.Write "<message>" & message & "</message>" & vbnewline Response.Write "<nowtime>" & Now() & "</nowtime>" & vbnewline Response.Write "</root>" & vbnewline Function regUser(username,pwd,email,PageName,PageURL) ''''''''''''''''''' '''''''''''''''''' ''''''''''''''''' ' cao zuo shu ju ku zhu ce yong hu ''''''''''''''''' '''''''''''''' regUser = "OK" End Function %> xia zai di zhi :http://www.shouji138.com/files/Xmlcls.rar yan shi di zhi :http://www.shouji138.com/aspnet2/sendxml.asp
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
清凉一夏_清纯美丽
纯白色小礼服
靓丽可人儿_嘉嘉
我的女神_靓丽女生
主题摄影
贵州,让我欢喜,让我神伤。
莫干山
天平秋色
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有