CSS selector select some part of div class name
css, css-selectors, html, xpath
Solution
Fizzler
To select an element with only the class `enabled_disabled`, you would use:
`[class='enabled_disabled']`
Using a `:not` selector is not available in vanilla Fizzler, but can be used if you grab FizzlerEx
XPath
To select an element with only the class `enabled_disabled`, you would use:
`div[@class='enabled_disabled']`
In plain old CSS
If the div's assigned classes starts with `enabled_disabled`:
`div[class^=enabled_disabled ]`
If the div's assigned classes contains `enabled_disabled`
`div[class*=enabled_disabled ]`
If the div only has the class `enabled_disabled`
`div[class=enabled_disabled ]`
If the div has the class `enabled_disabled` and not the class `disabled`
`div.enabled_disabled:not(.disabled)`
Given the HTML you list in your question, either of the last two will work for you.
more on attribute selectors from MDN, and, more on :not()
Problem
Select one part of text in div class: ``` <div class="enabled_disabled disabled"> <div class="enabled_disabled"> <div class="enabled_disabled"> <div class="enabled_disabled"> <div class="enabled_disabled disabled"> ``` I have those div tags, is there any xpath syntax or fizzler CSS selectors syntax to select just those div tags which have enabled_disabled only (the 3 in the middle)? not those with enabled_disabled disabled ``` var html = new HtmlDocument(); html.LoadHtml(getitems); var doc = html.DocumentNode; var items = (from r in doc.QuerySelectorAll("div.enabled_disabled:not(.disabled)") let Name = r.InnerHtml//QuerySelector("div.enabled_disabled div.title_bar div.rate_title span.name").InnerText.CleanInnerText() select new { CName = Name }).ToArray(); ```