2
我使用HTMLAgility
解析HTML文檔。解析HTML以獲取密鑰和值
我把它從codeplex和referenced
下載到我的項目。
現在,所有我需要的是分析此HTML(如下圖):
<HTML>
<BODY>
//......................
<tbody ID='image'>
<tr><td>Video Codec</td><td colspan=2>JPEG (8192 KBytes)</td></tr>
</BODY>
現在,我需要找回Video Codec
從上面的HTML它的價值JPEG
。
我知道我可以使用HTMLAgility
但如何做到這一點?
var document = new HtmlDocument();
string htmlString = "<tbody ID='image'>";
document.LoadHtml(htmlString);
// how to get the Video Codec and its value `JPEG` ?
任何指針非常感謝。
編輯:
我能夠從@itedi的回答繼續了一下,但還是堅持了。
var cells = document.DocumentNode
// use the right XPath rather than looping manually
.SelectNodes(@"//table")
.ToList();
var tbodies = cells.First().SelectNodes(@"//tbody").ToList();
給了我所有的tbody
的,但如何從中打印值?
可能重複:http://stackoverflow.com/questions/4573012/parsing-tables-如果不是這樣的話,那麼這個應該可以幫助你。 – jamespick
@itedi:謝謝itedi。請看我的編輯。我能夠繼續達到指定的點,然後開始工作。任何指針都非常有幫助。再次感謝你。 –