Html Agility Pack ends-with does not work
I tried to use ends-with
in Html Agility Pack in the following mode: //span[ends-with(@id, 'Label2')]
and //span[end开发者_高级运维s-with(., 'test')]
, but it does not work.
All other functions, like starts-with
and contains
work well.
Can anyone help me?
There can be found a hack! It is something like this:
//span['Label2'=substring(@id, string-length(@id)-string-length('_Label2')+1)]
Yes; it isn't supported, neither here nor in XmlDocument
. Perhaps iterate manually over //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);
}
精彩评论