今天图老师小编给大家精心推荐个Asp实现获取xml中的内容教程,一起来看看过程究竟如何进行吧!喜欢还请点个赞哦~
【 tulaoshi.com - Web开发 】
note.xml中的内容
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)?xml version="1.0" encoding="gb2312"?
channel
item
title新浪/title
linkhttp://www.sina.com.cn/link
/item
item
titlegoogle/title
linkhttp://www.google.cn/link
/item
item
title百度/title
linkhttp://www.baidu.com/link
/item
/channel
index.asp中的内容
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)%
h=GetLocationURL()'获取当前地址
h1=Split(h,"/")
h=Replace(h,h1(UBound(h1)),"note.xml")
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET",h,False
http.send
Set xml=Server.CreateObject("Microsoft.XMLDOM")
xml.Async=False
xml.ValidateOnParse=False
xml.Load(http.ResponseXML)
If xml.ReadyState2 Then
Response.Write("文档已经准备就绪。状态:"& xml.ReadyState &"
")
Set item=xml.getElementsByTagName("item")
For i=0 To (item.Length-1)
Set title=item.Item(i).getElementsByTagName("title")
Set link=item.Item(i).getElementsByTagName("link")
Response.Write("a href="""& link.Item(0).Text &""" target=""_blank"""& title.Item(0).Text &"/a
")
Next
Else
Response.Write("文档还未准备就绪。状态:"& xml.ReadyState &"
")
End If
Set http=Nothing
Set xml=Nothing
%
%
Function GetLocationURL()
Dim Url
Dim ServerPort,ServerName,ScriptName,QueryString
ServerName = Request.ServerVariables("SERVER_NAME")
ServerPort = Request.ServerVariables("SERVER_PORT")
ScriptName = Request.ServerVariables("SCRIPT_NAME")
QueryString = Request.ServerVariables("QUERY_STRING")
Url="http://"&ServerName
If ServerPort "80" Then Url = Url & ":" & ServerPort
Url=Url&ScriptName
If QueryString "" Then Url=Url&"?"& QueryString
GetLocationURL=Url
End Function
%
来源:http://www.tulaoshi.com/n/20160219/1622562.html
看过《Asp实现获取xml中的内容》的人还看了以下文章 更多>>