我尝试ends-with
在以下模式下在 Html Agility Pack 中使用://span[ends-with(@id, 'Label2')]
and //span[ends-with(., 'test')]
,但它不起作用。
所有其他功能,喜欢starts-with
并且运行contains
良好。
谁能帮我?
我尝试ends-with
在以下模式下在 Html Agility Pack 中使用://span[ends-with(@id, 'Label2')]
and //span[ends-with(., 'test')]
,但它不起作用。
所有其他功能,喜欢starts-with
并且运行contains
良好。
谁能帮我?
可以找到一个hack!它是这样的:
//span['Label2'=substring(@id, string-length(@id)-string-length('_Label2')+1)]
是的; 它不受支持,无论是在此处还是在XmlDocument
. 也许手动迭代//span[@id]
?
foreach (var node in from HtmlNode n in doc.DocumentNode.SelectNodes(@"//span[@id]")
where n.GetAttributeValue("id","").EndsWith("Label2")
select n)
{
Console.WriteLine(node.OuterHtml);
}