我正在启用ASP的 Windows Server上构建一个站点.我需要从另一台服务器检索XML文档并返回该文档中的值. xml文件很小 – 只有一个带有文本值的节点.我只需要返回该文本值.我以前从未使用过
<% Dim URL, objXML URL = "http://someserver.com/xml" Set objXML = Server.CreateObject("MSXML2.DOMDocument.4.0") objXML.setProperty "ServerHTTPRequest", True objXML.async = False objXML.Load(URL) If objXML.parseError.errorCode <> 0 Then Response.Write(objXML.parseError.reason) Response.Write(objXML.parseError.errorCode) End If Set oRoot = objXML.selectSingleNode("//xml/response") var = oRoot.text set objXML = nothing %> <%= var %>
===========
更新:
是的,你对我的XML完全正确.只有一个带有值的节点.根据您的意见,我将我的asp代码编辑为:
<% Dim URL, objXML, value URL = "http://someserver.com/xml" Set objXML = Server.CreateObject("MSXML2.DOMDocument.6.0") objXML.setProperty "ServerHTTPRequest", True objXML.async = False objXML.Load URL Response.Write objXML.parseError.reason value = objXML.documentElement.Text set objXML = nothing %> <%= value %>
哪个仍然返回500.如何调试ASP?有没有办法打开详细的错误报告?
我写了这个函数:<% Option Explicit Response.Buffer = True Dim xml Set xml = Server.CreateObject("Microsoft.XMLDOM") xml.async = False xml.setProperty "ServerHTTPRequest", True xml.Load ("http://www.midominio.com/nombre.xml") Dim title, heading, paragraph, testHTML title = xml.documentElement.childNodes(0).text heading = xml.documentElement.childNodes(1).text paragraph = xml.documentElement.childNodes(2).text testHTML = xml.documentElement.childNodes(3).text Set xml = Nothing %> <html> <head> <title><%= title %></title> </head> <body> <h3 align="center"><%= heading %></h3> <p align="center"><% = paragraph %></p> <div align="center"><%= testHTML %></div> </body> </html>