You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just starting out with this library, and trying to extract all the elements in an html doc, that have a specific class name, and that also have a style attribute that has a specific inline defined value.
My elements are inside a hierarchy that looks like this body > table > tbody > tr > td
The collection of p elements I am interested look like this
<p class="s11" style="padding-top: 1pt;padding-left: 1pt;text-indent: 0pt;line-height: 8pt;text-align: left;"> MY TEXT </p>
Any guidance would be appreciated
The text was updated successfully, but these errors were encountered:
You can get to the paragraph elements using p.s11[style]. This will get you all p elements with the class s11 and some attribute style. Then if you want to further refine the selection based on the actual content of the style attribute then you could continue to that in LINQ. Here's an example doing just that if the style attribute has CSS property named text-align with a value of left:
varq=fromein doc.DocumentNode.QuerySelectorAll("p.s11[style]")where e.GetAttributeValue("style",string.Empty).Split(';').Select(p => p.Split(new[]{':'},2)).Where(p => p.Length ==2).Select(p =>new{ Name = p[0].Trim(), Value = p[1].Trim()}).Any(p => p.Name =="text-align"&& p.Value =="left")selecte;
Just starting out with this library, and trying to extract all the elements in an html doc, that have a specific class name, and that also have a style attribute that has a specific inline defined value.
My elements are inside a hierarchy that looks like this
body > table > tbody > tr > td
The collection of p elements I am interested look like this
<p class="s11" style="padding-top: 1pt;padding-left: 1pt;text-indent: 0pt;line-height: 8pt;text-align: left;"> MY TEXT </p>
Any guidance would be appreciated
The text was updated successfully, but these errors were encountered: