Asp.net 使用xquery处理WebClient数据
我使用asp.net vb从跨域网页检索htmlAsp.net 使用xquery处理WebClient数据,asp.net,vb.net,xquery,Asp.net,Vb.net,Xquery,我使用asp.net vb从跨域网页检索html Dim objWebClient As New WebClient() objWebClient.UseDefaultCredentials = True objWebClient.Headers.Add(HttpRequestHeader.UserAgent, "XPlorer") 'STEP 2: Call the DownloadedData method Const strURL As Stri
Dim objWebClient As New WebClient()
objWebClient.UseDefaultCredentials = True
objWebClient.Headers.Add(HttpRequestHeader.UserAgent, "XPlorer")
'STEP 2: Call the DownloadedData method
Const strURL As String = "http://www.example.com"
Dim aRequestedHTML() As Byte
aRequestedHTML = objWebClient.DownloadData(strURL)
'STEP 3: Convert the Byte array into a String
Dim objUTF8 As New UTF8Encoding()
Dim strRequestedHTML As String
strRequestedHTML = objUTF8.GetString(aRequestedHTML)
另外,我想在文本控件中显示它的一部分。作为一个例子,我只想显示带有类“result”的表
如何在VB.NET的XML和XQuery中进一步处理这个问题?如何将strRequestedHTML声明为XML,如何在其中使用xquery
thx提前…如果您谈论的是网页(html),最好将其解析为html而不是XML。 是一个很好的.NET开源HTML解析器 您也可以使用Html Agility Pack下载网页 比如:
Dim htmlWeb As HtmlAgilityPack.HtmlWeb = New HtmlWeb()
Dim htmlDocument As HtmlAgilityPack.HtmlDocument = htmlWeb.Load("http://www.google.com")
Dim htmlNode As HtmlAgilityPack.HtmlNode = htmlDocument.DocumentNode.SelectSingleNode("//table[@class='result']")
Response.Write(htmlNode)