Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用xquery处理WebClient数据_Asp.net_Vb.net_Xquery - Fatal编程技术网

Asp.net 使用xquery处理WebClient数据

Asp.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

我使用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 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)