Html Agility Pack get all elements by class
- by Adam
I am taking a stab at html agility pack and having trouble finding the right way to go about this.
For example:
var findclasses = _doc.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class"));
However, obviously you can add classes to a lot more then divs so I tried this..
var allLinksWithDivAndClass = _doc.DocumentNode.SelectNodes("//*[@class=\"float\"]");
But that doesn't handle the cases where you add multiple classes and "float" is just one of them like this..
class="className float anotherclassName"
Is there a way to handle all of this? I basically want to select all nodes that have a class = and contains float.