我的项目有问题。我得到的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 –