首 页  –  网络编程    数据库    网页设计工具   网页脚本语言    美术设计理论    服务器技术
· 网店模板
· 设为首页
· 收藏本网
当前位置: 首页> 网络编程> XML教程> Asp实现获取xml中的内容


Asp实现获取xml中的内容

note.xml中的内容


<?xml version="1.0" encoding="gb2312"?>
<channel>
<item>
<title>新浪</title>
<link>http://www.sina.com.cn</link>
</item>
<item>
<title>google</title>
<link>http://www.google.cn</link>
</item>
<item>
<title>百度</title>
<link>http://www.baidu.com</link>
</item>
</channel>

index.asp中的内容


<%
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.ReadyState>2 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
%>


Tags:Asp实现获取xml中的内容
上一篇文章:没有了
下一篇文章:XML入门教程:XML CDATA
阅读热门榜
最新更新
网页设计大本营 版权所有
武动乾坤 斗破苍穹2 傲视遮天 link 美团贵阳团购网
Copyright ®2008 Www.Code-123.Com All Rights Reserved