0
我試圖解析HTML網頁,但源的格式不正確:解析畸形的HTML與HtmlAgilityPack
<div class=\"item column-1\">
<h2><a href=\"/index.php">Bridgestone recebe um Volkswagen Group Award</a></h2>
<dl class=\"article-info\"><dt class=\"article-info-term\">Detalhes</dt><dd class=\"create\">04-08-2015</dd></dl>
<p style=\"color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: normal;\">
<img src=\"images/Bridgestone-VWGroup.jpg\" width=\"600\" height=\"400\" alt=\"Bridgestone-VWGroup\">
</p>
<p style=\"color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: normal;\">
A Bridgestone acaba de receber um Volkswagen Group Award como reconhecimento pelo trabalho desenvolvido enquanto fornecedor daquele grupo, um prémio atribuído a um lote restrito de fornecedores internacionais
<div class=\"css_buttons1\" style=\"min-height:40px;display: inline-block;width: 425px;\">
<div class=\"css_fb_share\" style=\"display:inline-block;\"><fb:share-button href=\"http://anossaoficina.com/index.php" type=\"button_count\"></fb:share-button></div></div>
<p class=\"readmore\">
<a href=\"/index.php?">Continuar... Bridgestone recebe um Volkswagen Group Award</a></p>
<div class=\"item-separator\"></div>
</div>
<span class=\"row-separator\"></span>
</div>
我需要提取第二P- innexText「A普利司通......」但HtmlAgilityPack返回「」因爲這個標籤有一個開始<p>
,但不具備</p>
將其關閉:
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load("http://anossaoficina.com/index.php?option=com_content&view=category&layout=blog&id=78&Itemid=474");
foreach (var matchingDiv in doc.DocumentNode.SelectNodes("//*[contains(@class,'item column-1')]"))
{
var DescritionShort = matchingDiv.SelectSingleNode("./p[1]").InnerText;
}
您好,感謝!它很棒!非常感謝你 :) – Patrick