如何对xml文件做出响应? [英] How to make response of xml file?

查看:92
本文介绍了如何对xml文件做出响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的asp页面尝试xml请求/回复



Request.asp

$
  ;&NBSP;&NBSP; <%

   &NBSP;&NBSP;&NBSP;   pXML ="< XmlRequest>< FileNo> 123< / FileNo>< / XmlRequest>"

   &NBSP;&NBSP;&NBSP;  设置http = CreateObject(" MSXML2.ServerXMLHTTP")

   &NBSP;&NBSP;&NBSP;   http.open" GET"," http://test.com/response.asp?xml_request =" &安培; pXML,0
$
   &NBSP;&NBSP;&NBSP;   http.setRequestHeader" Content-Type"," application / x-www-form-urlencoded"

   &NBSP;&NBSP;&NBSP;   http.send""

   &NBSP;&NBSP;&NBSP;   http_response = http.responseText

    %>



Response.asp



    <%

    xml_request = Request.QueryString(" xml_request")

    

   设置xd = Server.CreateObject(" Msxml2.DOMDocument")

    xd.async = False

    xd.loadXML(Xml_Request)

    

    FileNo = xd.getElementsByTagName(" XmlRequest")。item(0).getElementsByTagName(" FileNo")。item(0).text

    '''这是问题

    %>
$


响应文件位于此服务器路径`Server.MapPath(" 123.xml")`(这是一个大文件)



如何将响应文件发送到"Request.asp"来自"Response.asp"

Below is my asp pages trying for xml request/response

Request.asp

    <%
        pXML = "<XmlRequest><FileNo>123</FileNo></XmlRequest>"
        Set http = CreateObject("MSXML2.ServerXMLHTTP")
        http.open "GET", "http://test.com/response.asp?xml_request=" & pXML, 0
        http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        http.send ""
        http_response = http.responseText
    %>

Response.asp

    <%
    xml_request = Request.QueryString("xml_request")
    
    Set xd= Server.CreateObject("Msxml2.DOMDocument")
    xd.async = False
    xd.loadXML(Xml_Request)
    
    FileNo = xd.getElementsByTagName("XmlRequest").item(0).getElementsByTagName("FileNo").item(0).text
    ''' here is the problem
    %>

Response file is in this server path `Server.MapPath("123.xml")` (this is a large file)

How i send response file to the "Request.asp" from "Response.asp"

推荐答案

如果只是与经典ASP相关,请使用经典的ASP论坛来解答您的问题。如果您想首先将XML文档加载到MSXML DOMDocument中以将其发送到客户端,您可以尝试

Please use a classic ASP forum for your questions if they simply relate to classic ASP. If you want to load an XML document first into an MSXML DOMDocument to send it then to the client you can try

 昏暗的文档

  Dim doc

 设置doc = CreateObject(" Msxml2.DOMDocument.3.0")

  Set doc = CreateObject("Msxml2.DOMDocument.3.0")

  doc.async = False

  doc.async = False

 如果doc.load(Server.MapPath(" 123.xml")))那么

  If doc.load(Server.MapPath("123.xml")) Then

    Response.ContentType =" application / xml"

    Response.ContentType = "application/xml"

    doc.Save Response

    doc.Save Response

 否则

    '在这里处理123.xml中的错误

    ' handle error in 123.xml here

 结束如果


这篇关于如何对xml文件做出响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆