我的項目有問題。我得到的HTML從一個網站,然後我想用XPath來的SelectSingleNode,這是內容的HTML:c#SelectNodes XPath忽略標記HTML內容的情況
<html>
<body>
<div>
<h3 class="bp">Groups you are in</h3>
</div> </body> </html>
,這是我的代碼:
var xpath = string.Format("//html/body/div/h3[.= '{0}'","groups you are in")
var header = BuildDom("{this is link website i get html}").SelectSingleNode(xpath);
這是我的課BuildDom:
HtmlNode BuildDom(string url)
{
string htmlContent = _http.DownloadContent(url);
return HtmlHelper.BuildDom(htmlContent);
}
PLZ看看:
var header = BuildDom("{this is link website i get html}").SelectSingleNode(xpath);
標題將爲空;因爲在HTML標籤H3:組你在
,並在我的XPath:「組你在」
我怎樣才能使用XPath使用「組你是?」忽略HTML中的標籤h3中的個案。 我不能將我的xpath更改爲「您所在的羣組」,因爲在html中,有時是您所在的h3內容「羣組」,有時候內容爲「您所在的羣組」或「您在羣組中」
重要注意事項:小寫只適用於XSLT 2.0。如果你使用1.0你可以使用下面的解決方法http://stackoverflow.com/questions/8976570/xpath-lower-case-function – Andre
:(它does not工作兄弟,標題stll null –
非常感謝你,它的工作原理! !:D –