利用ASP从远程服务器上接收XML数据的方法
程序员文章站
2023-08-13 22:23:46
复制代码 代码如下:<% dim objxml dim objrootelement dim str...
复制代码 代码如下:
<%
dim objxml
dim objrootelement
dim strvalue
dim strineturl
dim strxml
dim item
strineturl ="http://pf.inetsolution.com/inetactive2001/inetactive2001news.xml"
dim httpreq
set httpreq = server.createobject("msxml2.xmlhttp")
httpreq.open "get", "http://pf.inetsolution.com/inetactive2001/inetactive2001news.xml", false
httpreq.send
strxml = httpreq.responsetext
set objxml = server.createobject("msxml2.domdocument")
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://pf.inetsolution.com/inetactive2001/inetactive2001news.xml"
dim httpreq
set httpreq = server.createobject("msxml2.xmlhttp")
httpreq.open "get", "http://pf.inetsolution.com/inetactive2001/inetactive2001news.xml", false
httpreq.send
strxml = httpreq.responsetext
set objxml = server.createobject("msxml2.domdocument")
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
%>