Agility Pack选择SingleNode @id包含或@id就像

时间:2014-11-01 21:35:10

标签: c# html-agility-pack selectsinglenode

Html Agility Pack SelectSingleNode中是否有任何功能可以让我搜索类似的ID?

寻找类似

的内容
string str = node.SelectSingleNode("//td[@id **contains** 'id_']/span/text()")
                 .InnerText;

string str = node.SelectSingleNode("//td[@id **startsWith** 'id_']/span/text()")
                 .InnerText;

1 个答案:

答案 0 :(得分:2)

有XPath函数contains()starts-with(),完全按照您的意愿。这些函数的示例用法:

string str1 = node.SelectSingleNode("//td[contains(@id, 'id_')]/span/text()")
                  .InnerText;
string str2 = node.SelectSingleNode("//td[starts-with(@id, 'id_')]/span/text()")
                  .InnerText;