newsservice.asmx

来自「asp做的新闻系统」· ASMX 代码 · 共 44 行

ASMX
44 行
字号
<%@ 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 + =
减小字号Ctrl + -
显示快捷键?