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 
%>
运行index.asp文件

时间: 2024-08-01 12:37:20

asp获取xml中的内容的相关文章

用Asp获取Dll加密新闻内容

以下是代码:<%on error resume next  Dim objXMLHTTP, xml  Set xml = Server.CreateObject("Microsoft.XMLHTTP")   xml.Open "GET", "http://chanye.finance.sina.com.cn/yj/2005-01-05/236914.shtml", False  xml.Send  tmpstr= xml.responseT

android-manifest.xml中filter内容是取的交集么

问题描述 manifest.xml中filter内容是取的交集么 <data android:scheme="http" /> <data android:scheme="https" /> <data android:scheme="file" /> <data android:scheme="inline" /> <data android:mimeType="

厉害的用Asp获取Dll加密新闻内容_应用技巧

以下是代码: 复制代码 代码如下: <%  on error resume next    Dim objXMLHTTP, xml    Set xml = Server.CreateObject("Microsoft.XMLHTTP")     xml.Open "GET", "http://chanye.finance.sina.com.cn/yj/2005-01-05/236914.shtml", False    xml.Send 

.NET更新Xml中CDATA内容的方法实例

这篇文章介绍了.NET更新Xml中CDATA内容的方法实例,有需要的朋友可以参考一下    假如 Xml 文件的内容如下: 1.XML 代码 复制代码 代码如下: <?xml version="1.0" encoding="utf-8"?> <net_lover>   <sitename><![CDATA[<h2>.NET 开发</h2>]]></sitename>   <si

android-点击listview中的item跳转并获取item中的内容出现的问题

问题描述 点击listview中的item跳转并获取item中的内容出现的问题 一用settext()里面写上title就出错了 打印出来的title desc确实传递到另一个activity了 解决方案 文本数据传递到第二个Activity后,这句话报了空针,那就说明textView为null.你debug一下,看看是否是这个控件没有被实例化;或者你实例化错了控件(同样的id,导入的别的Activity下的) 解决方案二: 明确告诉你空指针了,你调试看看是哪个对象,然后检查是不是key写错了

javascript-用jquery先获取li中的内容,然后在span中输出

问题描述 用jquery先获取li中的内容,然后在span中输出 如图 我需要将每个大li标签里面选择好的li里面内容显示到上面span标签里面,点击选择了的li里面会加个class="selected",这个要用jquery来实现吗?要怎么写呢?本人js有点薄弱,希望能详细些 解决方案 楼主,你好,针对你的问题,想要实现其实也十分简单,我用你的问题截图,举一个简单的例子,里面有详细的注释,你先看,如果不懂的可以问我.下面这个是个简单的实现,还可以扩展功能,使他们适用于更多的地方.在下

jsp获取表格中的内容,没有id的情况下,

问题描述 jsp获取表格中的内容,没有id的情况下, 点击修改可以获取该行的id或者标题都行,因为这里用了遍历,所以每次点击都获取的是最后一行的id值.<%for(int i=0;i int id=list.get(i).getN_id(); String name = list.get(i).getN_title(); String date=list.get(i).getN_publishTime(); %> <%=id %> <%session.setAttribute

android获取Dialog中edittext内容时空指针异常求解决

问题描述 android获取Dialog中edittext内容时空指针异常求解决 import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.widge

利用Asp.net Ajax异步获取xml文档内容

ajax|asp.net|xml|异步 Ajax原意本是让人利用异步获取XML内容,以实现无刷新的网页效果asp.net ajax已将底层内容封装实现起来远比自写xmlhttp来的方便,至少浏览器兼容方面要强得很多下面以一个www.asp.net的示例说明一下利用microsoft ajax library来简单异步获取xml文档的方法 // 返回XML的Web 请求function OnSucceededXml(executor, eventArgs) ...{    if (executor