?? newsservice.asmx
字號:
<%@ WebService Language="VB" Class="NewsList" %>
Imports system
Imports System.Xml
Imports System.Web
Imports System.Web.Services
Public Class NewsList :Inherits WebService
<WebMethod()> Public Function GetNewsList() As String()
Dim newslist() As String
Dim source As New XmlDocument()
Dim objnode As XMlNode
Dim i As Integer
'載入新聞列表的XML文件
source.Load(Server.MapPath("contents.xml"))
objnode=source.SelectSingleNode("topiclist")
'生成新聞標題列表
If objnode.HasChildNodes Then
ReDim newslist(objnode.ChildNodes.Count)
For i=0 to objnode.ChildNodes.Count-1
newslist(i)=objnode.ChildNodes(i).ChildNodes(0).InnerText
Next
End If
GetNewsList=newslist
End Function
<WebMethod()> Public Function GeturlList() As String()
Dim urllist() As String
Dim source As New XmlDocument()
Dim objnode As XMlNode
Dim i As Integer
Dim url As String="http://localhost/dreamsite/ch08/"
'載入新聞列表的XML文件
source.Load(Server.MapPath("contents.xml"))
objnode=source.SelectSingleNode("topiclist")
'生成新聞鏈接列表
If objnode.HasChildNodes Then
ReDim urllist(objnode.ChildNodes.Count)
For i=0 to objnode.ChildNodes.Count-1
urllist(i)=url & objnode.ChildNodes(i).ChildNodes(1).InnerText
Next
End If
GeturlList=urllist
End Function
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -