2013-09-30 19 views
0

我得到的“span文本”这段代码,但我想要链接href(而不是链接文本)。 请帮助我。获取链接在<span>

Dim html As String = "<span class=myclass><a href=abc.html>text text a text</a></span>" 
    Dim doc = New HtmlAgilityPack.HtmlDocument() 
    doc.LoadHtml(html) 
    Dim titles As HtmlAgilityPack.HtmlNodeCollection = doc.DocumentNode.SelectNodes("//span[@class='myclass']") 
    For Each title In titles 
     MsgBox(title.InnerText) 
    Next 

回答

2

你问如何获得_attribute的价值:

title.Attributes("href").Value 
+0

非常感谢你。 – Blueman