Agility Pack Select SingleNode @id contains or @id is like

c# html-agility-pack selectsinglenode

Question

Is there any functionality in Html Agility Pack SelectSingleNode to let me search similiar IDs?

Looking for something like

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

or

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

Accepted Answer

There are XPath functions contains() and starts-with(), exactly as you wish. Example usage of those functions :

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



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why