2
我試圖獲取維基百科數據使用Special:Export
獲取數據:出口
以下是我的標記,我無法理解爲什麼它沒有進入while循環?我沒有得到任何錯誤。請幫助。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim webRequest As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create("http://en.wikipedia.org/wiki/Special:Export/Train"), HttpWebRequest)
webRequest.Credentials = System.Net.CredentialCache.DefaultCredentials
webRequest.Accept = "text/xml"
webRequest.UserAgent = "foo/bar"
Dim webResponse As System.Net.HttpWebResponse = CType(webRequest.GetResponse, HttpWebResponse)
Dim responseStream As System.IO.Stream = webResponse.GetResponseStream
Dim reader As System.Xml.XmlTextReader = New XmlTextReader(responseStream)
Dim NS As String = "http://www.mediawiki.org/xml/export-0.4/"
Dim doc As XPathDocument = New XPathDocument(reader)
reader.Close()
webResponse.Close()
Dim myXPathNavigator As XPathNavigator = doc.CreateNavigator
Dim nodesText As XPathNodeIterator = myXPathNavigator.SelectDescendants("text", NS, False)
While nodesText.MoveNext
Response.Write((nodesText.Current.InnerXml + " "))
End While
End Sub
如果它沒有進入循環,它會做什麼?它是否會拋出異常? – svick
不,沒有例外。 – Monodeep
你可以在你的系統中試試嗎? – Monodeep