大家好,我就是这样的3个div: div 1:
<div class="productbox-container first" style="float:left">
<div class="product">
<div class="product_image">
</div>
<div class="product_price">
</div>
</div>
</div>
div 2:
<div class="productbox-container" style="float:left">
<div class="product">
<div class="product_image">
</div>
<div class="product_price">
</div>
</div>
</div>
div 3:
<div class="productbox-container last" style="float:left">
<div class="product">
<div class="product_image">
</div>
<div class="product_price">
</div>
</div>
</div>
HtmlNodeCollection htmlNodeCollection = document.DocumentNode.SelectNodes("//*[@class='productbox-container first']");
HtmlNodeCollection htmlNodeCollection2 = document.DocumentNode.SelectNodes("//*[@class='productbox-container']");
HtmlNodeCollection htmlNodeCollection3 = document.DocumentNode.SelectNodes("//*[@class='productbox-container last']");
无论如何都要获得1 HtmlNodeCollection?有点像:
HtmlNodeCollection htmlNodeCollection3 = document.DocumentNode.SelectNodes("//*[@class='productbox-container'+*]");
使用*喜欢sql?谢谢你的帮助
答案 0 :(得分:2)
使用包含:
HtmlNodeCollection htmlNodeCollection3 = document.DocumentNode.SelectNodes("//*[contains(@class, 'productbox-container')]");
或更可靠:
HtmlNodeCollection htmlNodeCollection3 = document.DocumentNode.SelectNodes("//*[contains(concat(' ', @class, ' '), ' productbox-container ')]");