asp如何读取并解析远程xml文件
展开全部
用XMLHTTP获取,代码如下:
<%
dim objXML
dim objRootElement
dim strValue
dim strInetURL
dim strXML
dim item
strInetURL ="http://www.amwaynet.com.cn/content/data/nthmtg.xml"
Dim HttpReq
set HttpReq = server.CreateObject("Microsoft.XMLHTTP")
HttpReq.open "GET","http://www.amwaynet.com.cn/content/data/nthmtg.xml",False
HttpReq.send
strXML = HttpReq.responseText
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateonparse = true
objXML.async=false
objXML.loadXML(strXML)
if objXML.ParseError.errorCode <> 0 then
Response.Write("Error: " & objXML.parseError.reason & "<br>")
Response.Write("Code: 0x" & hex(objXML.parseError.errorCode) & "<br>")
Response.Write("At Line: " & objXML.parseError.line & "<br>")
Response.Write("At pos: " & objXML.parseError.linePos & "<br>")
else
set objRootElement = objXML.documentElement
if not isObject(objRootElement) then
Response.Write("no file loaded")
else
Response.Write(objRootElement.childnodes(0).text)
end if
end if
%>
<%
dim objXML
dim objRootElement
dim strValue
dim strInetURL
dim strXML
dim item
strInetURL ="http://www.amwaynet.com.cn/content/data/nthmtg.xml"
Dim HttpReq
set HttpReq = server.CreateObject("Microsoft.XMLHTTP")
HttpReq.open "GET","http://www.amwaynet.com.cn/content/data/nthmtg.xml",False
HttpReq.send
strXML = HttpReq.responseText
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateonparse = true
objXML.async=false
objXML.loadXML(strXML)
if objXML.ParseError.errorCode <> 0 then
Response.Write("Error: " & objXML.parseError.reason & "<br>")
Response.Write("Code: 0x" & hex(objXML.parseError.errorCode) & "<br>")
Response.Write("At Line: " & objXML.parseError.line & "<br>")
Response.Write("At pos: " & objXML.parseError.linePos & "<br>")
else
set objRootElement = objXML.documentElement
if not isObject(objRootElement) then
Response.Write("no file loaded")
else
Response.Write(objRootElement.childnodes(0).text)
end if
end if
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用 send
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询