我知道有很多XPath href問題,但沒有一個適合我的情況,或者我是它的初學者,不知道我的代碼出了什麼問題。如果這是一個愚蠢的問題,請耐心等待。XPath到href屬性&WriteLine的URL
我有這樣的HTML結構:
<td valign="top">08-Jan-14 16:02</td>
<td valign="top"><span style="cursor:help;" title="Regulatory News Service">RNS</span></td>
<td valign="top"><a href="share-regulatory-news.asp?shareprice=BARC&ArticleCode=d6rr2uxo&ArticleHeadline=Blocklisting_Interim_Review" class="linkStoryHeadline rnsArticle" title="Blocklisting Interim Review">Blocklisting Interim Review</a></td>
<td valign="top">Company Announcement - General</td>
我的代碼是:
HtmlNodeCollection cols5 = rows[i].SelectNodes(".//td[3]/a[@href]");
流作家寫的網址:
sw.WriteLine(cols5[j].InnerText);
結果似乎是Blocklisting Interim Review
代替網址。任何人都可以好好研究一下嗎?我已經通過XPath指南並搜索了所有內容,但仍無法獲得我的案例的確切答案。任何幫助將非常感激!
如果您最終將添加@href,該怎麼辦? .//td[3]/a[@href]/@href – Darka