<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      用ASP與Microsoft.XMLDOM區分遠程XML文件

      [摘要]用xmldom方法打開xml文件,如果是本地的沒有問題,就是用Server.MapPath("xml.xml")的方法,這時能正常分析出內容,但是直接用url卻不顯示出xml內容(在XMLDOM里表示是支持URL方式的),后來研究一下發現可以用XMLHTTP的方法獲取XML后再...

          用xmldom方法打開xml文件,如果是本地的沒有問題,就是用Server.MapPath("xml.xml")的方法,這時能正常分析出內容,但是直接用url卻不顯示出xml內容(在XMLDOM里表示是支持URL方式的),后來研究一下發現可以用XMLHTTP的方法獲取XML后再分析,代碼如下:

      Set http=Server.CreateObject("Microsoft.XMLHTTP")
      http.Open "GET","http://www.knowsky.com/xml.xml",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 &"<br>")
              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 &""">"& title.Item(0).Text &"</a><br>")
              Next
      Else
              Response.Write("文檔還未準備就緒。狀態:"& xml.ReadyState &"<br>")
      End If
      Set http=Nothing
      Set xml=Nothing


      xml.xml文檔的內容如下:

      <?xml version="1.0" encoding="utf-8"?>
      <channel>
      <item>
        <title>測試文檔1</title>
        <link>http://localhost/</link>
      </item>
      <item>
        <title>測試文檔2</title>
        <link>http://localhostindex.asp</link>
      </item>
      </channel>




      日韩精品一区二区三区高清