我试图用 ends-with 在Html灵活性组在以下方式: //span[ends-with(@id, 'Label2')]//span[ends-with(., 'test')] 但它不工作。

所有其他的功能,像 starts-withcontains 很好的工作。

任何人都可以帮我吗?

有帮助吗?

解决方案

有可以发现一个黑客! 它是这样的:

//跨度[ 'Label2的'=子(@id,串长度(@id)-string长度( '_ 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);
 }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top