selectnodes使用显示交易数据的股票网站的xPath(htmlagilitypack)错误(vb.net)

selectnodes使用显示交易数据的股票网站的xPath(htmlagilitypack)错误(vb.net),vb.net,parsing,xpath,Vb.net,Parsing,Xpath,错误点是作为htmlnode的每个节点的。 错误:其他信息:对象引用未设置为对象的实例。 Dim webClient As New System.Net.WebClient Dim WebSource As String = webClient.DownloadString("http://boc.quotepower.com/web/bochk/stocks_mktTransactions.jsp?lang=en&stock=811&lotsize=100&am

错误点是作为htmlnode的每个节点的

错误:
其他信息:对象引用未设置为对象的实例。

    Dim webClient As New System.Net.WebClient
    Dim WebSource As String = webClient.DownloadString("http://boc.quotepower.com/web/bochk/stocks_mktTransactions.jsp?lang=en&stock=811&lotsize=100&searchType=2&turnover=500000&rangeType=1&begin_hour=9&begin_min=30&end_hour=16&end_min=0&lang=zh_TW&domain=BOCHK&rand=-1076862387&lastLevel1Name=nav_stocks&lastStock=00005&x=0&y=0") '
    txtPageHTML.Text = WebSource

    Dim links As New List(Of String)()
    Dim htmlDoc As New HtmlAgilityPack.HtmlDocument()
    htmlDoc.LoadHtml(WebSource)
    '/html/body/table[4]/tbody/tr/td/table/tbody/tr/td/table[2]/tbody
    '/html/body/table[4]/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[2]
    For Each node As HtmlNode In htmlDoc.DocumentNode.SelectNodes("/html/body/table[4]/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[2]")
        txtPageHTML = node.InnerText
    Next
预期结果如下:

Time    Price   Volume  Turnover    No. of Lots     Above/Below Market Price
15:19:40    7.0     75K     525K    75  
15:01:54    7.05    83K     585.15K 83  
15:01:33    7.04    116K    816.64K 116 

应该是
htmlDoc.DocumentNode.SelectNodes(“/html/body/table[4]/tr/td/table/tr/td/table[2]/tr[2]”)

不要被您的web浏览器误导,它会修复文档,使其包含缺少的元素,如
tbody

编辑:要逐个获取单元格,请枚举行,然后枚举单元格:

For Each row As HtmlNode In htmlDoc.DocumentNode.SelectNodes("/html/body/table[4]/tr/td/table/tr/td/table[2]/tr")
    For Each cell As HtmlNode In row.SelectNodes("td")
        'Do something with cell.InnerText
    Next
Next

谢谢,我知道了。我可以得到那些字符串,但每一行都合并成一行。我无法使用该字符串进行进一步处理,也无法使用xpath:htmlDoc.DocumentNode.SelectNodes(“/html/body/table[4]/tr/td/table/tr/td/table[2]将每个项目逐个存储或存储到数组中?说一个循环?谢谢15:19:407.075K525K75 15:01:547.0583K585.15K83 15:01:337.04116K816.64K116 15:01:337.0377K541.31K77…可能是