Xpath is determined whether a property with or without the specified attribute or value

When combined extracts InnerText Xpath path in a circular list of HTML tags, the extracted attributes of this class is the need to determine whether the tag contains a property value specified by the contains Xpath can be solved, as follows:

//选择不包含class属性的节点
var result = node.SelectNodes(".//span[not(@class)]");
//选择不包含class和id属性的节点
var result = node.SelectNodes(".//span[not(@class) and not(@id)]");
//选择不包含class="expire"的span
var result = node.SelectNodes(".//span[not(contains(@class,'expire'))]");
//选择包含class="expire"的span
var result = node.SelectNodes(".//span[contains(@class,'expire')]");

 

Guess you like

Origin blog.csdn.net/caorya/article/details/81839928